go 冒泡排序

时间:2022-09-07 06:02:20
package main

import (
"fmt"
) func main() {
a := [...]int{, , , , , , , , , }
num := len(a)
fmt.Println(a)
for i := ; i < num; i++ {
for j := i + ; j < num; j++ {
if a[i] < a[j] {
temp := a[i]
a[i] = a[j]
a[j] = temp
} }
}
fmt.Println(a)
}

[ `go run test1.go` | done: 195.80006ms ]
    [12 32 434 765 34 8 94 12 34 53]
    [765 434 94 53 34 34 32 12 12 8]