有如下通用过程: Function Fs(ByVal n As Long) As Long Dim k As Long k = 1 n = Abs(n) Do While n k = k * (n Mod 1

admin2015-06-30  51

问题 有如下通用过程:
Function Fs(ByVal n As Long) As Long
    Dim k As Long
    k = 1
    n = Abs(n)
    Do While n
        k = k * (n Mod 10)
        n = n \ 10
    Loop
    Fs = k
End Function
编写如下事件过程:
Private Sub Form_Click()
    Dim a As Long
    Dim b As Long
    a = InputBox("请输入一个数")
    a = CLng(A)
    b = Fs(A)
    Print b
End Sub
程序运行后,单击窗体,在输入对话框中输入567,输出结果为

选项 A、56
B、67
C、210
D、18

答案C

解析 A的值为256,调用Fs函数,执行3次循环:第1次,k=7,n = 56 ;第2次,k=7*6 = 42,n = 5 ;第3次,k= 42*5 = 210,n = 0;不满足循环条件,退出循环。故正确答案为选项C。
转载请注明原文地址:https://jikaoti.com/ti/3160FFFM
0

最新回复(0)