主页 > 知识库 > asp下几种常用排序算法

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

'输出数组
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
%>

标签:儋州 雅安 广元 江门 锡林郭勒盟 七台河 新余 宣城

巨人网络通讯声明:本文标题《asp下几种常用排序算法》,本文关键词  asp,下,几种,常用,排序,算法,;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 下面列出与本文章《asp下几种常用排序算法》相关的同类信息!
  • 本页收集关于asp下几种常用排序算法的相关信息资讯供网民参考!
  • 推荐文章