设有以下函数过程: Function fun(a As Integer,b As Integer) Dim C As Integer Ifa

admin2018-10-15  9

问题 设有以下函数过程:
Function fun(a As Integer,b As Integer)
    Dim C As Integer
    Ifa           c=a:a=b:b=c
    End if
    c=0
    Do
           c=c+3
    Loop until c Mod b=0
    fun=c
End Function
    若调用函数fun时的实际参数都是自然数,则函数返回的是

选项 A、a、b的最大公约数
B、a、b的最小公倍数
C、a除以b的余数
D、a除以b的商的整数部分

答案B

解析 本题考查循环结构的使用。在fun函数中,首先判断a和b的大小,并把a和b中大的保存在a当中,小的保存在b当中。然后进入循环,在循环体内部,c如果不能整除b则每次增加a,这是求a和b的最小公倍数。
转载请注明原文地址:https://kaotiyun.com/show/EUFp777K
0

随机试题
最新回复(0)