vb代码希尔排序算法的代码。
收起
知与谁同
2018-07-17 20:20:15
1839
0
1
条回答
写回答
取消
提交回答
-
Sub shellsort(ByRef a() As Single) '希尔排序算法,对数组a进行排序
Dim i, j, gap As Integer
Dim k, x, n As Integer
n = UBound(a)
gap = Int(n / 2)
While gap > 0
For i = gap + 1 To n
j = i - gap
While j > 0
If a(j) < a(j + gap) Then
x = a(j)
a(j) = a(j + gap)
a(j + gap) = x
j = j - gap
Else
j = 0
End If
End While
Next i
gap = Int(gap / 2)
End While
End Sub
2019-07-17 22:50:47