package main
import "fmt"
//冒泡排序
func BubbleSort(list []int) {
for i := len(list) - 1; i > 0; i-- {
for j := 0; j < i; j++ {
if list[j] > list[j+1] {
list[j], list[j+1] = list[j+1], list[j]
}
}
}
return
}
func main() {
list := []int{5, 9, 1, 6, 8, 14, 6, 25, 4, 6, 3}
BubbleSort(list)
fmt.Println(list)
}
评论(0)