135-1821-9792

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

其他资讯



Copyright © 2009-2022 www.kswsj.com 成都快上网科技有限公司 版权所有 蜀ICP备19037934号