package main
import "fmt"
func main() {
var arr []int
arr = []int{3, 4, 9, 6, 7, 1, 2}
res := cSort(arr)
fmt.Println(res)
}
func cSort(arr []int) []int {
var tmp, tmpIndex int
count := len(arr)
for i := 0; i < count-1; i++ {
tmpIndex = i
for j := i+1; j < count; j++ {
if arr[j] < arr[tmpIndex] {
tmpIndex = j
}
}
tmp = arr[tmpIndex]
arr[tmpIndex] = arr[i]
arr[i] = tmp
}
return arr
}
有疑问加站长微信联系(非本文作者)