直接排序 快速排序 冒泡排序法都可以 从小到大排
Private Sub Command1_Click()
Dim a(1 To 5, 1 To 10) As Integer
For i = 1 To 5
For j = 1 To 10
a(i, j) = Int(Rnd * 90) + 10
Print a(i, j);
Next j
Next i
For i = 1 To 49
i1 = (i - 1) \ 10 + 1
j1 = (i - 1) Mod 10 + 1
i3 = i1: j3 = j1
For j = i + 1 To 50
i2 = (j - 1) \ 10 + 1
j2 = (j - 1) Mod 10 + 1
If a(i2, j2) > a(i3, j3) Then
i3 = i2
j3 = j2
End If
Next j
t = a(i1, j1): a(i1, j1) = a(i3, j3): a(i3, j3) = t
Next i
Print "排序以后:"
For i = 1 To 5
For j = 1 To 10
Print a(i, j);
Next j
Next i
End Sub