(29) 以下能够正确计算n!的程序是
A) Private Sub Command1_Click()
n=5: x=1
Do
x=x * I
I=I + 1
Loop While I < n
Print x
End Sub
B) Private Sub Command1_Click()
n=5: x=1: I=1
Do
x=x * I
I=I + 1
Loop While I < n
Print x
End Sub
C) Private Sub Command1_Click()
n=5: x=1: I=1
Do
x=x * I
I=I + 1
Loop While I <=n
Print x
End Sub
D) Private Sub Command1_Click()
n=5: x=1: I=1
Do
x=x * I
I=I + 1
Loop While I > n
Print x
End Sub
正确答案: C
(30) 下列程序段,在运行时最后输出的内容是
a=2
c=1
AAA:
c=c + a
If c < 10 Then
Print c
GoTo AAA
Else
Print "10以内的奇数显示完毕"
End If
A) 3
B) 7
C) 9
D) 10以内的奇数显示完毕
正确答案: D
(31) 单击命令按钮时,下列程序的执行结果为
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer
a=2: b=3: c=4
Print P2(c, b, A)
End Sub
Private Function P1(x As Integer, y As Integer, z As Integer)
P1=2 * x + y + 3 * z
End Function
Private Function P2(x As Integer, y As Integer, z As Integer)
P2=P1(z, x, y) + x
End Function
A) 21
B) 19
C) 17
D) 34
正确答案: A
(32) 单击命令按钮时,下列程序的执行结果是
Private Sub Book(x As Integer)
x=x * 2 + 1
If x < 6 Then
Call Book(x)
End If
x=x * 2 + 1
Print x;
End Sub
Private Sub Command2_Click()
Book 2
End Sub
A) 23 47
B) 10 36
C) 22 44
D) 24 50
正确答案: A
(33) 有如下程序:
Private Sub Command1_Click()
Dim k As Integer, m As Integer
Dim p As Integer
k=4: m=1
p=PC(k, m) : Print p;
p=PC(k, m) : Print p
End Sub
Private Function PC(a As Integer, b As Integer)
Static m As Integer, i As Integer
m=0: i=2
i=i + m + 1
m=i + a + b
PC=m
End Function
程序运行后,输出的结果为
A) 4 6
B) 6 6
C) 8 8
D) 10 12
正确答案: C
(34) 有如下程序:
Private Sub Command1_Click()
Dim a As Single
Dim b As Single
a=5: b=4
Call S(a, b)
End Sub
Sub S(x As Single, y As Single)
t=x
x=t \ y
y=t Mod y
End Sub
在调用运行上述程序后,a和b的值分别为
A) 0 0
B) 1 1
C) 2 2
D) 1 2
正确答案: B
(35) 在窗体上画一个命令按钮,然后编写下列程序:
Private Sub Command12_Click()
Tt 3
End Sub
Sub Tt(a As Integer)
Static x As Integer
x=x * a + 1
Print x;
End Sub
连续三次单击命令按钮,输出的结果是
A) 1 5 8
B) 1 4 13
C) 3 7 4
D) 2 4 8
正确答案: B