📄 form0322.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "起泡法排序"
ClientHeight = 2370
ClientLeft = 60
ClientTop = 345
ClientWidth = 4995
LinkTopic = "Form1"
ScaleHeight = 2370
ScaleWidth = 4995
StartUpPosition = 3 '窗口缺省
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Base 1
Private Sub Form_Click()
'起泡法排序
Const N = 10
Dim a(N) As Integer
Dim i As Integer, j As Integer, t As Integer
Randomize
Print
Print "显示排序前的A元素:"
'产生1到100间的随机整数
For i = 1 To N
a(i) = Int(Rnd * 100) + 1
Print a(i);
Next i
For j = 1 To N - 1
For i = 1 To N - j
If a(i) > a(i + 1) Then '相邻的数比较并调换顺序
t = a(i) 't为中间变量
a(i) = a(i + 1)
a(i + 1) = t
End If
Next i
Next j
Print
Print "显示排序后的A元素:"
For i = 1 To N
Print a(i); '在窗口显示排序后的A元素
Next i
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -