以下是 使用泡沬排序法,由小至大排列 的程式
如何改成快速排序法呢???????
Dim Num(8) As Integer
Private Sub Ascend_cmd_Click()
n = 0
For i = 1 To 8
a = Rnd * 10
n = n + 1 '亂數取八個數值 放入陣列中'
Num(n) = CInt(a)
Next i
For i = 7 To 1 Step -1
For j = 1 To i
If Num(j) > Num(j + 1) Then
temp_val = Num(j)
Num(j) = Num(j + 1)
Num(j + 1) = temp_val
End If
Next j
Next i
End Sub