用VB编写一个判断两个正整数的最大公因数的程序怎么写啊???????? 各位帮帮忙啊
展开全部
Private Sub Command1_Click()
a = InputBox("请输入数值")
b = InputBox("请输入数值")
If Val(a) < Val(b) Then
For i = 1 To Val(a)
If Val(a) Mod i = 0 And Val(b) Mod i = 0 Then c = i
Next
Else
For i = 1 To Val(b)
If Val(a) Mod i = 0 And Val(b) Mod i = 0 Then c = i
Next
End If
Print c
End Sub
a = InputBox("请输入数值")
b = InputBox("请输入数值")
If Val(a) < Val(b) Then
For i = 1 To Val(a)
If Val(a) Mod i = 0 And Val(b) Mod i = 0 Then c = i
Next
Else
For i = 1 To Val(b)
If Val(a) Mod i = 0 And Val(b) Mod i = 0 Then c = i
Next
End If
Print c
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询