单选题
VB
题号 #484517
设有函数
,下面不能正确求该函数值的程序段是( )
A. SelectCase x
Case Is<0
y=x
Case 0
y=0
Case Is>0
y=x*x
End Select
B.If x>0 Then
y=x*x
End If
If x=0Then
y=0
End If
If x<0 Then
v=x
End If
C.If x<0Then
y=x
Else lf x>0 Then
y=x*x
Else
y=0
End If
D.If x<=0Then
y=x
End If
If X<>0Then
y=x*x
Else
y=0
End
参考答案
D
答案解析
对于选项D,"-3 x>0是,Y的值为o;当x=0时,y的值0;"-3 x<0时,Y的值为0。显然不能正确求原函数值。
你可能感兴趣的试题
A.Select Case语句中的测试表达式可以是任何形式的表达式
B.Select Case语句中的测试表达式只能是数值表达式或字符串表达式
C.在执行Select Case语句时,所有Case子句均按出现的次序被顺序执行
D.如下Select Case语句中的Case表达式是错误的
Select Case x
Case 1 to 10
End Select
Select Case x
Case 1 to 10
End Select
A.1 2 3 4
B.2 3 4 5
C.2 3 4 4
D.3 4 5 6