A.7
B.10
C.5
D.8
解析:∵x1=2,x2=3,
∴x1≠x2.
∴y=x1+x2=2+3=5.
答案:C
7.运行下列算法语句后,输出的结果为 .
x=-1
y=20
If x<0 Then
x=y+3
Else
y=y-3
End If
输出x-y,x+y.
解析:因为x=-1<0,
所以x=20+3=23.
因为y=20,所以x-y=3,x+y=43.
答案:3,43
8.执行如下算法语句:
输入x;
If x>=0 Then
y=x2-6x+11
Else
y=x2+10x+27
End If
输出y.
要使输出的y值最小,则输入的x的值为 .
解析:执行此算法语句的功能是求函数y={■(x^2 "-" 6x+11"," x≥0"," @x^2+10x+27"," x<0)┤的函数值.
由函数的性质知,当x=3或x=-5时,y有最小值2.
答案:3或-5
9.已知符号函数y=sgn x的定义为y={■(1"," x>0"," @0"," x=0"," @"-" 1"," x<0"," )┤试编写算法语句,使输入x的值输出相应y的值.
解算法语句如下:
输入x;
If x>0 Then