x=5;if x<;=-10 y=x+1;elseif -10<;x<;=10 y=x+2;else y=x+3;end The final value of y is 7.
举一反三
- if 结构中,以下用法正确的是( ) A: if (2<i<=3)iend B: if y>x elseif y<x else y==x end C: if (x<10){ y=x+1;} D: if x>0y=sin(x);elsey=cos(x);end
- 【单选题】针对下列分段函数: 下列哪个程序段存在逻辑错误 。 A. if(x<0) y=x+1; if(x>=0 && x<10) y=x*x-5; if(x>=10) y=x*x*x; B. if(x<0) y=x+1; else if(x<10) y=x*x-5; else y=x*x*x; C. if(x<10) y=x*x-5; else if(x<0) y=x+1; else y=x*x*x; D. if(x<0) y=x+1; else if(x>=10) y=x*x*x; else y=x*x-5;
- 【单选题】分段函数: ,下面程序段中正确的是__________。 A. If x < 0 Then y = 0 If x < 1 Then y = 1 If x < 2 Then y = 2 If x >= 2 Then y = 3 B. If x >= 2 Then y = 3 If x >= 1 Then y = 2 If x > 0 Then y = 1 If x < 0 Then y = 0 C. If x < 0 Then y = 0 ElseIf x > 0 Then y = 1 ElseIf x > 1 Then y = 2 Else y = 3 End If D. If x > =2 Then y = 3 ElseIf x > =1 Then y = 2 ElseIf x > =0 Then y = 1 Else y = 0 End If
- 执行下列程序段后,变量y的值为( )。 Dim x As Integer,y As Integer x = 7 y = 3 If x >= 10 Then y = x - y ElseIf x>= 7 Then y = x + y Else y = x End If A: 21 B: 10 C: 4 D: 3
- 执行下列事件过程,y的值为。 Private Sub Command1_Click() x = 3 If x > 10 Then y = x ^ 2 + 3 * x + 2 Else If x > 5 Then y = 3 * x + 2 Else y = 5 End If End If End Sub