📄 5-6.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 6975
ClientLeft = 60
ClientTop = 405
ClientWidth = 5310
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
ScaleHeight = 6975
ScaleWidth = 5310
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "素数排序"
Height = 615
Left = 2760
TabIndex = 5
Top = 5640
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "生成"
Height = 495
Left = 600
TabIndex = 4
Top = 5640
Width = 1215
End
Begin VB.ListBox List2
Height = 4785
ItemData = "5-6.frx":0000
Left = 2640
List = "5-6.frx":0002
TabIndex = 3
Top = 600
Width = 1695
End
Begin VB.ListBox List1
Height = 4785
ItemData = "5-6.frx":0004
Left = 360
List = "5-6.frx":0006
TabIndex = 1
Top = 600
Width = 1695
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "素数排序:"
Height = 315
Left = 2640
TabIndex = 2
Top = 240
Width = 1575
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "数组元素:"
Height = 315
Left = 360
TabIndex = 0
Top = 240
Width = 1575
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim a(100) As Integer, b(100) As Integer
Private Sub Command1_Click()
List1.Clear: List2.Clear
Dim i As Integer
Randomize
For i = 1 To 100
a(i) = Int(Rnd * 90) + 10
List1.AddItem a(i)
Next i
End Sub
Private Sub Command2_Click()
Dim i As Integer, j As Integer, t As Integer
Dim n As Integer
n = 0
For i = 1 To 100
For j = 2 To Sqr(a(i))
If a(i) Mod j = 0 Then Exit For
Next j
If j > Sqr(a(i)) Then
n = n + 1: b(n) = a(i)
End If
Next i
For i = 1 To n - 1
For j = i + 1 To n
If b(j) > b(i) Then
t = b(j): b(j) = b(i): b(i) = t
End If
Next j
Next i
For i = 1 To n
List2.AddItem b(i)
Next i
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -