标签:selection 语言 nbsp sort 排序 span func cti class
/* 直接选择排序 */ func straightSelectionSorter(array []int) { for i := 0; i < len(array)-1; i++ { k := i for j := i + 1; j < len(array); j++ { if array[k] > array[j] { k = j } } if k != i { //交换k和i上面的值 temp := array[k] array[k] = array[i] array[i] = temp } } } func main() { var arr = []int{94, 12, 34, 76, 26, 9, 0, 37, 55, 76, 37, 5, 68, 83, 90, 37, 12, 65, 76, 49} straightSelectionSorter(arr) fmt.Println(arr) }
标签:selection 语言 nbsp sort 排序 span func cti class
原文地址:https://www.cnblogs.com/beanbag/p/13149515.html