[VBA ] 如何使用 QuickSort 的 VBA 程式 (網路流通的版本)
Sub QuickSort(a() As Double, f As Integer, e As Integer)
Dim i As Integer, j As Integer, X As Double, temp As Double
i = f: j = e
X = a((f + e) / 2, 1)
While i <= j
While (a(i, 1) > X And i < e)
i = i + 1
Wend
While (X > a(j, 1) And j > f)
j = j - 1
Wend
If i <= j Then
temp = a(i, 1)
a(i, 1) = a(j, 1)
a(j, 1) = temp
temp = a(i, 0)
a(i, 0) = a(j, 0)
a(j, 0) = temp
i = i + 1
j = j - 1
End If
Wend
If f < j Then Call QuickSort(a(), f, j)
If i < e Then Call QuickSort(a(), i, e)
End Sub
請問這樣怎麼改成 Function 的型式 ,讓我可以 自己放想要排序的陣列呢,並且傳出矩陣
謝謝大家 ...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.36.182.38
→
12/01 05:46, , 1F
12/01 05:46, 1F
→
12/01 09:08, , 2F
12/01 09:08, 2F