单击命令按钮时,下列程序的执行结果是 Private Sub Command1_Click() BT 4 End Sub Private Sub BT(x As Integer) x=x*2 + 1 If x < 6 Then Call BT

admin2013-04-11  21

问题  单击命令按钮时,下列程序的执行结果是
Private Sub Command1_Click()
BT 4
End Sub
Private Sub BT(x As Integer)
x=x*2 + 1
If x < 6 Then
Call BT(x)
End If
x=x  2
Print x;
End Sub

选项 A、15
B、16       
C、17
D、18

答案D

解析 此题在函数调用过程中采用了简单递归的方式,具体流程如下:主调过程调用BT过程,把实参4传递给BT过程中的形参x,由x=x2+1语句推出x=9,此时不满足BT过程中判断语句的判断条件,执行x=x2;Print x;语句。由x=x2语句得到x值为18并输出,结束此次调用过程,返回到主调过程结束程序,输出结果为18。
转载请注明原文地址:https://kaotiyun.com/show/1nQp777K
0

最新回复(0)