Go语言冒泡排序实现代码 2015/07/24 17362 package main import ( "fmt" ) func main() { A := []int{5, 21, 2, 4, 1} num := len(A) for i := 0; i < num; i++ { for j := i + 1; j < num; j++ { if A[i] > A[j] { A[i], A[j] = A[j], A[i] } } } fmt.Println(A) }