有如下函数过程: Function Fun (By Val x As Ingeger, ByVal y As Integer)As Integer Do While…y<>0 reminder=x Mod y

admin2013-04-11  28

问题 有如下函数过程:      Function Fun (By Val x As Ingeger, ByVal y As Integer)As Integer           Do While…y<>0         reminder=x Mod y        x=y        y=reminder      Loop      Fun=x    End Function    以下是调用该函数的事件过程,该程序的运行结果是    Private Sub Command1_Click()    Dim a As Integer    Dim b As Integer       a=100:b=25       x=Fun(a,b)Print x    End Sub

选项 A、0
B、25
C、50
D、100

答案2

解析 本题的难点是子函数调用过程。子函数Fun的功能是求x和y的公约数,由“欧几里德”求最大公约数的算法可知,当余数r为0时,x为x和y的最大公约数。变量,的值通过子函数名Fun返回。
转载请注明原文地址:https://kaotiyun.com/show/cnQp777K
0

相关试题推荐
最新回复(0)