📄 例11.frm
字号:
VERSION 5.00
Begin VB.Form frm8_7_6
Caption = "例11:利用递归求m,n的最大公约数"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 6270
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 6270
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "计算"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2040
TabIndex = 0
Top = 2400
Width = 2415
End
End
Attribute VB_Name = "frm8_7_6"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim x%, y%, gcdinxy%
Cls
x = CInt(InputBox("请输入第一个整数"))
y = CInt(InputBox("请输入第二个整数"))
Print x & "和" & y & "的最大公约数为" & greatcd(x, y)
End Sub
Public Function greatcd(m As Integer, n As Integer) As Integer
If (m Mod n = 0) Then
greatcd = n
Print m, n
Else
greatcd = greatcd(n, m Mod n)
Print m, n
End If
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -