Goang冒泡排序
func bubbleSort(arr []int) []int { arr_len := len(arr) for i := 0; i < arr_len; i++ { for j := i + 1; j < arr_len; j++ { if arr[i] < arr[j] { arr[j], arr[i] = arr[i], arr[j] } } } return arr } arr := []int{5, 43, 75, 1, 7, 6, 3, 11, 78, 2} res := bubbleSort(arr) fmt.Printf("res: %v\n", res)