📄 cxc10.frm
字号:
VERSION 5.00
Begin VB.Form cxc10
BackColor = &H00C0E0FF&
Caption = "直接选择排序(selectsort)"
ClientHeight = 7995
ClientLeft = 60
ClientTop = 450
ClientWidth = 10875
Icon = "cxc10.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 8545.09
ScaleMode = 0 'User
ScaleWidth = 11000
StartUpPosition = 3 '窗口缺省
Begin VB.ListBox List3
BackColor = &H00FFC0C0&
Height = 1680
Left = 5400
TabIndex = 17
Top = 5640
Width = 4695
End
Begin VB.ListBox List2
BackColor = &H00FFC0C0&
Height = 1500
Left = 5400
TabIndex = 16
Top = 3240
Width = 4695
End
Begin VB.Timer Timer2
Enabled = 0 'False
Interval = 5000
Left = 9240
Top = 2760
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 1000
Left = 3960
Top = 6480
End
Begin VB.TextBox Text1
BackColor = &H00FFC0C0&
Height = 735
Left = 5400
TabIndex = 12
Text = "Text1"
Top = 1680
Width = 4695
End
Begin VB.ListBox List1
BackColor = &H00C0FFC0&
BeginProperty Font
Name = "黑体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 5520
Left = 600
TabIndex = 11
Top = 1560
Width = 3855
End
Begin VB.Frame Frame1
BackColor = &H00C0C0FF&
Height = 975
Left = 0
TabIndex = 0
Top = -120
Width = 11000
Begin VB.Image Image9
Height = 240
Index = 2
Left = 9120
Picture = "cxc10.frx":0CCA
Top = 240
Width = 240
End
Begin VB.Label Label13
BackColor = &H00C0C0FF&
Caption = "递减排序"
Height = 255
Left = 9000
TabIndex = 10
Top = 600
Width = 735
End
Begin VB.Label Label4
Alignment = 2 'Center
BackColor = &H00C0C0FF&
Caption = "说 明"
Height = 255
Left = 120
TabIndex = 9
Top = 600
Width = 855
End
Begin VB.Image Image9
Height = 240
Index = 0
Left = 8040
Picture = "cxc10.frx":0DCC
Top = 240
Width = 240
End
Begin VB.Image Image8
Height = 225
Left = 10200
Picture = "cxc10.frx":0ECE
Top = 240
Width = 225
End
Begin VB.Image Image7
Height = 240
Left = 6960
Picture = "cxc10.frx":0FC8
Top = 240
Width = 240
End
Begin VB.Image Image6
Height = 225
Left = 4680
Picture = "cxc10.frx":10CA
Top = 240
Width = 225
End
Begin VB.Image Image5
Height = 270
Left = 5760
Picture = "cxc10.frx":11C4
Top = 240
Width = 240
End
Begin VB.Image Image10
Height = 225
Left = 3720
Picture = "cxc10.frx":12D6
Top = 240
Width = 225
End
Begin VB.Image Image11
Height = 225
Left = 2640
Picture = "cxc10.frx":13D0
Top = 240
Width = 225
End
Begin VB.Image Image12
Height = 240
Left = 1560
Picture = "cxc10.frx":14CA
Top = 240
Width = 240
End
Begin VB.Image Image13
Height = 240
Left = 480
Picture = "cxc10.frx":15CC
Top = 240
Width = 270
End
Begin VB.Label Label9
Alignment = 2 'Center
BackColor = &H00C0C0FF&
Caption = "返 回"
Height = 255
Left = 9840
TabIndex = 8
Top = 600
Width = 855
End
Begin VB.Label Label8
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H00C0C0FF&
Caption = "递增排序"
ForeColor = &H80000008&
Height = 255
Left = 7800
TabIndex = 7
Top = 600
Width = 855
End
Begin VB.Label Label7
Alignment = 2 'Center
BackColor = &H00C0C0FF&
Caption = "输入数据"
Height = 255
Left = 6600
TabIndex = 6
Top = 600
Width = 855
End
Begin VB.Label Label6
Alignment = 2 'Center
BackColor = &H00C0C0FF&
Caption = "继 续"
Height = 255
Left = 4440
TabIndex = 5
Top = 600
Width = 855
End
Begin VB.Label Label10
Alignment = 2 'Center
BackColor = &H00C0C0FF&
Caption = "单步运行"
Height = 255
Left = 5400
TabIndex = 4
Top = 600
Width = 855
End
Begin VB.Label Label11
Alignment = 2 'Center
BackColor = &H00C0C0FF&
Caption = "暂 停"
Height = 255
Left = 3360
TabIndex = 3
Top = 600
Width = 855
End
Begin VB.Label Label12
Alignment = 2 'Center
BackColor = &H00C0C0FF&
Caption = "自动运行"
Height = 255
Left = 2280
TabIndex = 2
Top = 600
Width = 855
End
Begin VB.Label Label1
Alignment = 2 'Center
BackColor = &H00C0C0FF&
Caption = "导入程序"
Height = 255
Index = 2
Left = 1200
TabIndex = 1
Top = 600
Width = 855
End
End
Begin VB.Label Label5
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "经直接选择排序排序后递减序列为:"
Height = 255
Left = 5520
TabIndex = 15
Top = 5280
Width = 4695
End
Begin VB.Label Label3
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "经直接选择排序排序后递增序列为:"
Height = 255
Left = 5520
TabIndex = 14
Top = 3000
Width = 4695
End
Begin VB.Label Label2
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "您输入的待排序序列为:"
Height = 255
Left = 5520
TabIndex = 13
Top = 1440
Width = 4695
End
End
Attribute VB_Name = "cxc10"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'**********************************************
'* desinded dy 丞相 E_mail:cxc-0378@163.com *
'**********************************************
Dim i, k As Integer
Dim a(100), c(10) As Integer
Dim b(10) As Variant
Private Sub Form_Load()
cxc10.Left = (Screen.Width - Width) / 2
cxc10.Top = (Screen.Height - Height) / 2
i = 0
a(0) = 3: a(1) = 4: a(2) = 5: a(3) = 6: a(4) = 7: a(5) = 8: a(6) = 10: a(7) = 11: a(8) = 12
a(9) = 3: a(10) = 4: a(11) = 5: a(12) = 8: a(13) = 10: a(14) = 11: a(15) = 12
a(16) = 3: a(17) = 4: a(18) = 5: a(19) = 6: a(20) = 7: a(21) = 8: a(22) = 10: a(23) = 11: a(24) = 12
a(25) = 3: a(26) = 4: a(27) = 5: a(28) = 8: a(29) = 10: a(30) = 11: a(31) = 12
a(32) = 3: a(33) = 4: a(34) = 5: a(35) = 6: a(36) = 7: a(37) = 8: a(38) = 10: a(39) = 11: a(40) = 12
a(41) = 3: a(42) = 4: a(43) = 5: a(44) = 8: a(45) = 10: a(46) = 11: a(47) = 12
a(48) = 3: a(49) = 4: a(50) = 5: a(51) = 6: a(52) = 7: a(53) = 8: a(54) = 10: a(55) = 11: a(56) = 12
a(57) = 3: a(58) = 4: a(59) = 5: a(60) = 8: a(61) = 10: a(62) = 11: a(63) = 12
c(0) = 0: c(1) = 1: c(2) = 2: c(3) = 3: c(4) = 4: c(5) = 5: c(6) = 6: c(7) = 7: c(8) = 8: c(9) = 9
End Sub
Sub Selection(MyArray(), ByVal nOrder As Integer)
Dim Index
Dim Min
Dim NextElement
Dim TEMP, gIterations
NextElement = 0
While (NextElement < UBound(MyArray))
Min = UBound(MyArray)
Index = Min - 1
While (Index >= NextElement)
If nOrder = 0 Then
If MyArray(Index) < MyArray(Min) Then
Min = Index
End If
ElseIf nOrder = 1 Then
If MyArray(Index) >= MyArray(Min) Then
Min = Index
End If
End If
Index = Index - 1
gIterations = gIterations + 1
Wend
TEMP = MyArray(Min)
MyArray(Min) = MyArray(NextElement)
MyArray(NextElement) = TEMP
NextElement = NextElement + 1
gIterations = gIterations - 1
Wend
End Sub
Private Sub Label1_Click(Index As Integer)
List1.AddItem ("直接选择排序(递增)自动运行显示")
List1.AddItem ("selectionsort()") '1
List1.AddItem ("{") '2
List1.AddItem ("for(i=1;i<n;++i)") '3
List1.AddItem ("j=i;") '4
List1.AddItem ("for(k=i+1;k<=n;k++)") '5
List1.AddItem ("if(r[k].key<r[j].key)") '6
List1.AddItem ("j=k;") '7
List1.AddItem ("if(i!=j)") '8
List1.AddItem ("{") '9
List1.AddItem ("temp=r[i];") '10
List1.AddItem ("r[i]=r[k];") '11
List1.AddItem ("r[k]=temp;") '12
List1.AddItem ("}") '13
List1.AddItem ("}") '14
End Sub
Private Sub Label10_Click()
Call Timer1_Timer
Call Timer2_Timer
End Sub
Private Sub Label11_Click()
Timer1.Enabled = False
Timer2.Enabled = False
End Sub
Private Sub Label12_Click()
Timer1.Enabled = True
Timer2.Enabled = True
End Sub
Private Sub Label13_Click()
Dim textstr As String
Call Selection(b, 1)
For i = 1 To 10
textstr = textstr + Str$(b(i)) + Space(1)
List3.AddItem "第" + Str$(i) + "趟:" + textstr
Next i
End Sub
Private Sub Label4_Click()
cxc13.Show
End Sub
Private Sub Label6_Click()
Timer1.Enabled = True
Timer2.Enabled = True
End Sub
Private Sub Label7_Click()
Dim i As Integer
Dim textstr As String
For i = 0 To 9
b(i) = InputBox("请逐个输入待排序序列(10个):")
If b(i) = "" Then
Exit For
End If
textstr = textstr + Str$(b(i)) + Space(1)
Text1.Text = textstr
Next i
End Sub
Private Sub Label8_Click()
Dim textstr As String
Call Selection(b, 0)
For i = 1 To 10
textstr = textstr + Str$(b(i)) + Space(1)
List2.AddItem "第" + Str$(i) + "趟:" + textstr
Next i
End Sub
Private Sub Label9_Click()
cxc02.Show
cxc10.Hide
End Sub
Private Sub Timer1_Timer()
If (i <= 100) Then
List1.Selected(a(i)) = True
End If
i = i + 1
End Sub
Private Sub Timer2_Timer()
If (k <= 10) Then
List2.Selected(c(k)) = True
End If
k = k + 1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -