📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BackColor = &H00E0E0E0&
Caption = "求最大公约数"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
FillColor = &H00C0C0C0&
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Left = 1440
TabIndex = 0
Top = 2160
Width = 1695
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Base 1
Function gcd(ByVal m%, ByVal n%) As Integer
If m < n Then t = m: m = n: n = t
Do
r = m Mod n
If r = 0 Then Exit Do
m = n
n = r
Loop
gcd = n
End Function
Private Sub Command1_Click()
Dim a() As Integer
n = InputBox("输入n")
ReDim a(n)
For i = 1 To n
a(i) = InputBox("输入数据")
Next i
n1 = a(1)
For i = 2 To n
m1 = a(i)
mn = gcd(m1, n1)
If mn = 1 Then Exit For Else n1 = mn
Next i
Print mn
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -