go(希尔排序)

package main

import "fmt"

func shellsortmax(arr []int,start int,gap int){
    length:=len(arr)
    for i:=start+gap;i= 0 && backup < arr[j]{
            arr[j+gap]=arr[j]
            j-=gap
        }
        arr[j+gap]=backup
    }
}

func shellsort(arr []int)([]int) {
    var length = len(arr)
    if length <= 1 {
        return arr
    }
    gap:=length/2
    for gap > 0{
        for i:=0;i

你可能感兴趣的:(go(希尔排序))