VB程序,编写一个用辗转相除法,求俩自然数m、n的最大公约数和最小公倍数.

VB程序,编写一个用辗转相除法,求俩自然数m、n的最大公约数和最小公倍数.
用DO……LOOP循环语句
其他人气:399 ℃时间:2020-04-12 22:04:41
优质解答
Private Sub command1_click()
Dim m As Integer,n As Integer
Dim a As Integer,b As Integer
Dim r As Integer
m = InputBox("输入m")
n = InputBox("输入n")
a = m
b = n
Do
r = Abs(m - n)
m = n
n = r
Loop While m n
Print a; "和"; b; "最大公约数是"; r
Print a; "和"; b; "最小公倍数是"; a * b / r
End Sub
我来回答
类似推荐
请使用1024x768 IE6.0或更高版本浏览器浏览本站点,以保证最佳阅读效果。本页提供作业小助手,一起搜作业以及作业好帮手最新版!
版权所有 CopyRight © 2012-2024 作业小助手 All Rights Reserved. 手机版