用随机数函数产生10个40内的整数,使用快速选择排序法从小到大排序

2024-12-01 18:15:52
推荐回答(1个)
回答1:

Option Explicit
Dim 数值(0 To 9) As IntegerPrivate Sub Command1_Click()
Dim i As Integer
Cls
For i = 0 To 9
数值(i) = Rnd * 40
Print 数值(i)
Next i
End SubPrivate Sub Form_Load()
Randomize
End SubPrivate Sub Command2_Click()
Dim i As Integer, j As Integer, tmp As Integer
Print "-------------"
For i = 0 To 9
For j = 0 To 9
If 数值(i) < 数值(j) Then
tmp = 数值(j)
数值(j) = 数值(i)
数值(i) = tmp
End If
Next j
Next i
For i = 0 To 9
Print 数值(i)
Next i
End Sub