MISڲ̳ղ
·
̳
 λãMISϵͳ & ǰ  
½ ע ̳  

  վ
  Χ ʽ ؼ(ÿոֿ)  

  ߼Ϣ ȶȣ94 % 
admin

֣73146
ȼվԱ
13451
ע᣺2004-7-20

 Ϣ     ҳ         

¥  

 asp¼ֳ㷨


<%
Dim aData
aData = Array(3,2,4,1,6,0)
Call ResponseArray(aData, "ԭ˳")
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 t<a_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

'
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
%>

2022/6/21 23:10:04 ༭

    2022/6/21 23:10:03 
  ¹ 0 ҳ, 0 Żģÿҳ 10 Ż >> [ ]
ҳ룺
Copyright 2003-2022 ClickSun All Rights Reserved