Go语言实现选择排序
package main import "fmt"
func SelectSort(num []int) {
for i := 0; i < len(num); i++ {
for j := i + 1; j < len(num); j++ {
if (num[i] > num[j]) {
num[i], num[j] = num[j], num[i]
}
}
}
}
func main() {
a := [...] int {1,5684,25,487,74,2,54894,51,65874,51,65,478}
SelectSort(a[:])
fmt.Println(a)
}