执行以下程序,MsgBox输出的值是________。Dim i, a(9) As Integera(0) = 1a(1) = 1For i = 2 To UBound(a)a(i) = a(i - 1) + a(i - 2)Next iMsgBox(a(9))
举一反三
- 以下程序输出的结果是___________ 。 Dim a(5), i As Integer For i = 0 To 5 a(i) = 2 * i + 1 Next i MsgBox(a(i)) A: 程序出错 B: 1 3 5 7 9 11 C: 11 D: 9 E: 不确定
- 使用数组x输出10个1-100之间的随机整数(包括1和100),下列命令中正确的是:( ) A: Dim x(9) As Integer For i = 1 To UBound(x) x(i) = Int(Rnd() * 100 + 1) Print x(i); Next B: Dim x(9) As Integer For i = 0 To UBound(x) x(i) = Rnd(10) Print x(i); Next C: Dim x(9) As Integer For i = 0 To UBound(x) x(i) = Int(Rnd() * 100 ) Print x(i); Next D: Dim x(9) As Integer For i = 0 To UBound(x) x(i) = Int(Rnd() * 100 + 1) Print x(i); Next
- 若有数组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)
- 下列程序的执行结果是______。 k =0 For i=1 To 3 a = i ^ i ^ k Print a; Next I A: 1 1 1 B: 1 2 3 C: 0 0 0 D: 1 4 9
- 以下程序段实现的输出是()。for(i=0;i<;=9;i++)s[i]=i;for(i=9;i>;=0;i--)printf("%2d",s[i]);[/i][/i] A: 9 7 5 3 1 B: 1 3 5 7 9 C: 9 8 7 6 5 4 3 2 1 0 D: 0 1 2 3 4 5 6 7 8 9