成都创新互联网站制作重庆分公司

希尔排序(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://cxhlcq.com/article/gcccsj.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部