第3个回答 2013-10-12
1、Private Sub Command1_Click() Dim N As Integer, bF As Boolean, dt As String Dim k As Integer, m As Integer, nn As Integer, mm As Integer, tt As String N = InputBox("请输入N值(N>100)") nn = 0: mm = 0: tt = "" For k = 3 To N bF = False For m = 2 To k - 1 If (k Mod m) = 0 Then bF = True Exit For End If Next If Not bF Then nn = nn + 1 mm = mm + 1 dt = CStr(k) tt = tt & Space(8 - Len(dt)) & dt If mm = 10 Then mm = 0 Print tt tt = "" End If End If NextEnd Sub2、Private Sub Command2_Click() Dim m As Integer, n As Integer, mm As Integer, nn As Integer Dim k As Integer, r As Integer m = InputBox("请输入一个自然数m") n = InputBox("请输入一个自然数n") mm = m: nn = n If m < n Then k = m: m = n: n = k End If Do r = m Mod n If r > 0 Then m = n: n = r End If Loop Until r = 0 MsgBox mm & "和" & nn & "的最大公约数是" & n End Sub]