从未排序的序列a[i+1:]中选择最小的值,存入a[i]
代码:
func ChooseSort(a []int){
for i:=0; i<len(a);i++ {
for j:=i+1;j<len(a);j++{
if a[j] < a[i] {
a[j],a[i] = a[i],a[j]
}
}
}
fmt.Println(a)
}
测试:
func main(){
a := []int{0,10,19,24,61,5,121,9,11,34,21,22}
base_sort.ChooseSort(a)//[0 5 9 10 11 19 21 22 24 34 61 121]
}