本文共 390 字,大约阅读时间需要 1 分钟。
1 2 3 4 5 6 7 8 9 10 11 12 13 | func shellSort(unsorted [] int , n int ) { var i, j, gap int var temp int for gap = n / 2 ; gap > 0 ; gap / = 2 { for i = gap; i < n; i + + { for j = i - gap; j> = 0 && unsorted[j]>unsorted[j + gap]; j - = gap { temp = unsourted[j] unsorted[j] = unsorted[j + gap] unsorted[j + gap] = temp } } } } |
转载地址:http://qbmpa.baihongyu.com/