求给定自然数m和n的最大公约数。请完善程序。 Private Sub Command1_Click() Dim m As Integer, n As Integer, r As Integer m = Text1.Text n = Text2.Text If m < n Then r = m: m = n: n = r Do r = m Mod n m = n n = r Loop Until__________ Text3.Text = m End Sub Private Sub Command2_Click() Dim m As Integer, n As Integer, r As Integer m = Text1.Text n = Text2.Text If m < n Then r = m: m = n: n = r r = m Mod n Do Until _______ m = n n = r r = m Mod n Loop Text3.Text =____ End Sub Private Sub Command3_Click() Dim m As Integer, n As Integer, r As Integer m = Text1.Text n = Text2.Text If m < n Then r = m: m = n: n = r Do r = m Mod n m = n n = r Loop While________ Text3.Text =______ End Sub Private Sub Command4_Click() Dim m As Integer, n As Integer, r As Integer m = Text1.Text n = Text2.Text If m < n Then r = m: m = n: n = r r = m Mod n Do While______ m = n n = r r = m Mod n Loop Text3.Text =____ End Sube73f1fd63959cc8362d8c82d419c2353.png
举一反三
- 下列计算最大公约数的递归过程,正确的是___________。 A: Sub gcd(ByVal m%, ByVal n%) Dim r% r = m n If r = 0 Then gcd = n Else gcd = gcd(n, r) End If End Sub B: Sub gcd(ByVal m%, ByVal n%) Dim r% r = m Mod n If r = 0 Then gcd = n Else gcd = gcd(n, r) End If End Sub C: Function gcd%(ByVal m%, ByVal n%) Dim r% r = m n If r = 0 Then gcd = n Else gcd = gcd(n, r) End If End Function D: Function gcd%(ByVal m%, ByVal n%) Dim r% r = m Mod n If r = 0 Then gcd = n Else gcd = gcd(n, r) End If End Function
- 下面程序的功能是用“辗转相除法”求两个正整数的最大公约数。请分析程序填空。#includemain(){intr,m,n;scanf("%d%d",&m,&n);if(m A: 【1】r=m,m=n,n=r;【2】m%n; B: 【1】m%n;【2】r=m,m=n,n=r; C: 【1】r=m,m=n,n=r;【2】n%m; D: 【1】n%m;【2】r=m,m=n,n=r;
- 设A为m×n矩阵,B为n×,n矩阵,若AB=E,则( ) A: r(A)=m,r(B)=m B: r(A)=m,r(B)=n C: r(A)=n,r(B)=m D: r(A)=n,r(B)=n
- 设A是m×n矩阵,B是n×m矩阵,E为m阶单位矩阵,若AB=E,则()。 A: r(A)=m,r(B)=m B: r(A)=m,r(B)=n C: r(A)=n,r(B)=m D: r(A)=n,r(B)=n
- 设A为m×n矩阵,B为n×m矩阵,E为m阶单位矩阵,若AB=E,则(). A: r(A)=m,r(B)=m B: r(A)=m,r(B)=n C: r(A)=n,r(B)=m D: r(A)=n,r(B)=n