希尔排序(Golang)
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 } } } }
分享题目:希尔排序(Golang)
文章网址:http://myzitong.com/article/gcccsj.html