阅读下面的程序代码: Private Sub Command1_Click() Print fun(748639,5) End Sub Private Function fun(x As Long,a As Integer)As Integer Dim n

admin2020-07-22  27

问题 阅读下面的程序代码:
Private Sub Command1_Click()
Print fun(748639,5)
End Sub
Private Function fun(x As Long,a As Integer)As
Integer
Dim n As Long
n=1
Do
n=n*10
a=a-1
Loop Until a=0
fun=hat((x Mod n)/(n/10))
End Function
此程序代码运行后的输出是(    )。

选项 A、3
B、4
C、48639
D、74863

答案B

解析 主调过程Command1_Click中调用函数过程fun,并将整数748639传递给形参x,将5传递给形参a,被调过程fun中循环执行情况及各变量的值如下表所示。

x mod n=748639 mod 100000=48639:n/10=100000/10=10000;故表达式Int((x Mod n)/(n/10))结果为Int(48639/10000)=4;所以B选项正确。
转载请注明原文地址:https://kaotiyun.com/show/nMHp777K
0

最新回复(0)