📄 素数.frm
字号:
VERSION 5.00
Begin VB.Form FRM5_4_4
BackColor = &H00FFC0C0&
Caption = "5-4-4:判断一个正整数是否为素数"
ClientHeight = 4020
ClientLeft = 60
ClientTop = 345
ClientWidth = 7050
LinkTopic = "Form1"
ScaleHeight = 4020
ScaleWidth = 7050
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 435
Left = 3960
TabIndex = 3
Top = 2280
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "判断"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3000
TabIndex = 2
Top = 3120
Width = 1455
End
Begin VB.Label Label2
BackColor = &H000000FF&
Caption = "请输入一个正整数:"
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 360
TabIndex = 1
Top = 2280
Width = 3255
End
Begin VB.Label Label1
BackColor = &H0080FFFF&
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1695
Left = 360
TabIndex = 0
Top = 240
Width = 6495
End
End
Attribute VB_Name = "FRM5_4_4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim n As Integer
n = Text1
k = Int(Sqr(n))
i = 2
SWIT = 0
Do While i <= k And SWIT = 0
If n Mod i = 0 Then
SWIT = 1
Else
i = i + 1
End If
Loop
If SWIT = 0 Then
MsgBox (Str(n) & "是一个素数!")
Else
MsgBox (Str(n) & "不是一个素数!")
End If
End Sub
Private Sub Form_Load()
FRM5_4_4.Show
Label1.Caption = " 只能被1和它本身整除的数称为素数,为了判别一个数n是不是素数,可以将n被2到根号n之间的所有整数除,如果都除不尽,则n就是素数,否则n是非素数."
Text1.SetFocus
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -