主頁(yè) > 知識(shí)庫(kù) > asp下幾種常用排序算法

asp下幾種常用排序算法

熱門標(biāo)簽:外呼系統(tǒng)怎么話費(fèi) 電銷機(jī)器人采購(gòu) 高質(zhì)量的電銷外呼系統(tǒng) 滴滴地圖標(biāo)注上車點(diǎn) 地圖標(biāo)注還可以做嗎 硅基電話機(jī)器人加盟 友邦互聯(lián)電銷機(jī)器人違法嗎 宿州防封外呼系統(tǒng)平臺(tái) 無(wú)營(yíng)業(yè)執(zhí)照地圖標(biāo)注教學(xué)
%

Dim aData
aData = Array(3,2,4,1,6,0)

Call ResponseArray(aData, "原來(lái)順序")
Call ResponseArray(SelectSort(aData), "選擇排序")
Call ResponseArray(QuickSort(aData), "快速排序")
Call ResponseArray(InsertSort(aData), "插入排序")
Call ResponseArray(BubbleSort(aData), "冒泡排序")


'選擇排序
Function SelectSort(a_Data)
Dim i, j, k
Dim bound, t
bound = UBound(a_Data)

For i = 0 To bound-1
k = i
For j = i+1 To bound
If a_Data(k) > a_Data(j) Then
k = j
End If
Next
t = a_Data(i)
a_Data(i) = a_Data(k)
a_Data(k) = t
Next

SelectSort = a_Data
End Function


'快速排序
Function QuickSort(a_Data)
Dim i, j
Dim bound, t
bound = UBound(a_Data)

For i = 0 To bound-1
For j = i+1 To bound
If a_Data(i) > a_Data(j) Then
t = a_Data(i)
a_Data(i) = a_Data(j)
a_Data(j) = t
End If
Next
Next

QuickSort = a_Data
End Function


'冒泡排序
Function BubbleSort(a_Data)
Dim bound
bound = UBound(a_Data)
Dim bSorted, i, t
bSorted = False

Do While bound > 0 And bSorted = False

bSorted = True
For i = 0 To bound-1
If a_Data(i) > a_Data(i+1) Then
t = a_Data(i)
a_Data(i) = a_Data(i+1)
a_Data(i+1) = t
bSorted = False
End If
Next
bound = bound - 1
Loop

BubbleSort = a_Data
End Function


'插入排序
Function InsertSort(a_Data)
Dim bound
bound = UBound(a_Data)
Dim i, j, t

For i = 1 To bound
t = a_Data(i)
j = i
Do While ta_Data(j-1) And j>0
a_Data(j) = a_Data(j-1)
j = j - 1
Loop
a_Data(j) = t
Next

InsertSort = a_Data
End Function

'輸出數(shù)組
Sub ResponseArray(a_Data, str)
Dim s
s = ""
Response.Write "b>" str ":/b>"
For i = 0 To UBound(a_Data)
s = s a_Data(i) ","
Next
s = Left(s, Len(s)-1)
Response.Write s
Response.Write "hr>"
End Sub
%>

標(biāo)簽:儋州 雅安 廣元 江門 錫林郭勒盟 七臺(tái)河 新余 宣城

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp下幾種常用排序算法》,本文關(guān)鍵詞  asp,下,幾種,常用,排序,算法,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp下幾種常用排序算法》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于asp下幾種常用排序算法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章