举一反三
- 编写如下程序: Private Sub Command1_Click() Dim x As Integer, y As Integer x = 1: y = 1 Do y = x * y If y > 10 Then Print x, y Exit Do Else x = x + 3 End If Loop While x <= 10 End Sub 运行程序,输出结果为______
- 执行下列事件过程,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
- 下面程序运行后,点击窗体,变量 x和y的值分别为( )、( ) Private Sub Form_Click() Dim x, y As Integer x = 5: y = 10 nc x, y Print "x="; x; "y="; y End Sub Private Sub nc(ByVal a%, b%) a = a + b b = a a = a * b End Sub
- 设有如下两个过程: Private Sub Form_Click() Dim x!,y! x = 18: y = 10 Call PPP((x), y) Print x,y End Sub Private Sub PPP(a As Single, b As Single) a = a + b Print a,b b = a + b Print a,b End Sub 运行程序后, 则输出结果是________
- 完成以下功能:计算分段函数完成程序。 x2+1 (x<0) y= 2x+1 (0≤x<1) 3x3 (x≥1) Private Sub Command1_Click() Dim y As Single, x As Single x = InputBox("请输入x的值") If x() Then y = x * x + 1 () x < 1 Then y = 2 * x + 1 Else y = 3 * x ^ 3 End If Print x; y End Sub
内容
- 0
有一程序段,其功能是:当x>0时,y=x;当-2=<x<=0时,y=-x,当x<-2时,产生一个“输入错误”信息框。则下列程序空白处应为_______。 Private Sub Form_Click() x % = InputBox("请输入x的值:") If x>0 Then y=x _______ y=-x Else MsgBox "输入错误" End If Print y End Sub A: Else x>=-2 And x<=0 Then B: ElseIf x>=-2 And x<=0 Then C: ElseIf x>=-2 And x<=0 D: Else If x>=-2 And x<=0 Then
- 1
在窗体上添加一个命令按钮,程序运行时单击Commandl后,窗体上的输出结果为。 Private Sub fun(a%, ByVal b%) a=a*2:b=b*2 End Sub Private Sub Command1_Click() Dim x%,y% x=10:y=20 Call fun(x, y) Print x; y End Sub
- 2
下面程序段执行结果为( )。 x = 5 : y = -6 If not x > 0 Then x = y – 3 Else y = x + 3 End If Print x - y; y - x
- 3
当输入4时,以下程序的输出结果是. Private Sub Command1_Click() x = Val(InputBox(x)) If x ^ 2 < 15 Then y = 1 / x If x ^ 2 > 15 Then y = x ^ 2 + 1 Print y End Sub
- 4
运行如下程序,输出结果是 。 try: x, y = 1, 0 z = x / y print(0, end=",") except: print("1", end=",") else: print("2", end=",") finally: print("3", end=",")