vb分别用子过程和子函数编写求两个数的最大公约数(算法用辗转相减法)
答案:2 悬赏:0 手机版
解决时间 2021-02-11 19:20
- 提问者网友:遁入空寂
- 2021-02-11 07:41
vb分别用子过程和子函数编写求两个数的最大公约数(算法用辗转相减法)
最佳答案
- 五星知识达人网友:上分大魔王
- 2021-02-11 07:56
Dim x As LongPrivate Sub Command1_Click() Dim a As Long, b As Long a = Val(InputBox(A=)) b = Val(InputBox(B=)) Call gcd(a, b) Print 用过程计算的; a; 和; b; 的最大公约数是:; x Print 用函数计算的; a; 和; b; 的最大公约数是:; gcd1(a, b)End SubPrivate Sub gcd(ByVal a As Long, ByVal b As Long) Dim r As Long Do r = a Mod b a = b b = r Loop Until r = 0 x = aEnd SubPrivate Function gcd1(ByVal a As Long, ByVal b As Long) As Long Dim r As Long Do r = a Mod b a = b b = r Loop Until r = 0 gcd1 = aEnd Function
全部回答
- 1楼网友:污到你湿
- 2021-02-11 09:24
收益了
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯