下面是一个数组降序的程序。
Ary(i) < Ary(j)改Ary(i) > Ary(j)就可改为升序数组。
请问各位大侠,你们还有什么更好方法。
Function Bubble_Sort(Ary)
Dim aryUBound, i, j
aryUBound = UBound(Ary)
For ii = 0 To aryUBound
Ary(ii) = Val(Round(Ary(ii), 2))
Next ii
For i = 0 To aryUBound
For j = i + 1 To aryUBound
If Ary(i) < Ary(j) Then
Swap Ary(i), Ary(j)
End If
Next
Next
Bubble_Sort = Ary
End FunctionFunction Swap(a, b)
Dim tmp
tmp = a
a = b
b = tmp
End Function
Ary(i) < Ary(j)改Ary(i) > Ary(j)就可改为升序数组。
请问各位大侠,你们还有什么更好方法。
Function Bubble_Sort(Ary)
Dim aryUBound, i, j
aryUBound = UBound(Ary)
For ii = 0 To aryUBound
Ary(ii) = Val(Round(Ary(ii), 2))
Next ii
For i = 0 To aryUBound
For j = i + 1 To aryUBound
If Ary(i) < Ary(j) Then
Swap Ary(i), Ary(j)
End If
Next
Next
Bubble_Sort = Ary
End FunctionFunction Swap(a, b)
Dim tmp
tmp = a
a = b
b = tmp
End Function
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货