新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

希尔排序(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://www.wjwzjz.com/article/gcccsj.html
在线咨询
服务热线
服务热线:028-86922220
TOP