若有数组Dim a%(10)且每个元素有值,统计前一个元素大于后一个元素的次数,结果存放在变量n中。则下列语句正确的是___________。
A: Dim i%, n% For i = 1 To 10 If a(i) > a(i + 1) Then
n = n + 1 End If Next MsgBox(n)
B: Dim i%, n% For i = 1 To 10 If a(i) > a(i + 1) Then
n = a(i) End If Next MsgBox(n)
C: Dim i%, n% For i = 0 To 9 If a(i) > a(i + 1) Then
a(i) = n + 1 End If Next MsgBox(n)
D: Dim i%, n% For i = 0 To 9 If a(i) > a(i + 1) Then
n = n +1 End If Next MsgBox(n)
A: Dim i%, n% For i = 1 To 10 If a(i) > a(i + 1) Then
n = n + 1 End If Next MsgBox(n)
B: Dim i%, n% For i = 1 To 10 If a(i) > a(i + 1) Then
n = a(i) End If Next MsgBox(n)
C: Dim i%, n% For i = 0 To 9 If a(i) > a(i + 1) Then
a(i) = n + 1 End If Next MsgBox(n)
D: Dim i%, n% For i = 0 To 9 If a(i) > a(i + 1) Then
n = n +1 End If Next MsgBox(n)
举一反三
- 下列程序段不能正确显示1!、2!、3!、4!的结果的是 。 A: For i = 1 To 4 For j = 1 To i n = 1 n = n * j Next j MsgBox( n)Next i B: Dim i%, j%, n%For i = 1 To 4 n = 1 For j = 1 To i n = n * j Next j MsgBox( n)Next i C: Dim j%, n%n = 1For j = 1 To 4 n = n * j MsgBox( n)Next j D: Dim j%, n%n = 1j = 1Do While j<=4 n=n*j MsgBox(n) j=j+1Loop E: Dim j%, n%n = 1j = 1Do n=n*j MsgBox(n) j=j+1Loop While j<=4
- 下列程序段能分别正确显示1!、2!、3!、4!的值的是______。 A: For i = 1 To 4 n = 1 For j = 1 To i n = n * j MsgBox(n) Next jNext i B: For i = 1 To 4 For j = 1 To i n = 1 n = n * j Next j MsgBox(n)Next i C: n = 1For i = 1 To 4 For j = 1 To 4 n = n * j MsgBox(n) Next jNext i D: n = 1j = 1Do While j <= 4 n = n * j MsgBox(n) j = j + 1Loop
- 下列程序段能且只能显示1!、2!、3!、4!的值的是( )。 A: For i = 1 To 4 n = 1 For j = 1 To i n = n * j Next j MsgBox(n)Next i B: For i = 1 To 4 For j = 1 To i n = 1 n = n * j Next j MsgBox(n)Next i C: n = 1For i = 1 To 4 For j = 1 To 4 n = n * j MsgBox(n) Next jNext i D: n = 1j = 1Do While j <= 4 n = n * j j = j + 1LoopMsgBox(n)
- 运行下面的程序,第二行显示结果是___________。 Private Sub Form_Click() Dim A As Integer Dim i As Integer A = 5 For i = 1 To 9 Call sub1(i, A) Print i, A Next i End Sub Private Sub sub1(x As Integer, y As Integer) Static N As Integer Dim I As Integer For I = 3 To 1 Step -1 N = N + x x = x + 2 Next I y = y + N End Sub
- 在窗体上有一命令按钮Command1,其Click事件代码如下: Private Sub Command1_Click() Dim a%, b%, i%, n% For i = 1 To 10 n = InputBox("请输入一个整数", "输入数据框", 2) If n Mod 2 = 0 Then a = a + 1 Else b = b + 1 End If Next i MsgBox ("运行结果a=" & str(a) & ", b=" & str(b)) End Sub