go排序-冒泡排序
package main
import "fmt"
func main() {
	var list  = []int{0,-3,234,234,12,435,43,2,23,2}
	bubbleSort(list)
	fmt.Println(list)
}
func bubbleSort(list []int)  {
	n := len(list)
	
	for i :=0;i<n-1;i++{
		for j:=0;j<n-1-i;j++{
			if list[j] > list[j+1]{
				list[j+1],list[j] = list[j],list[j+1]
			}
		}
	}
}
GOROOT=/usr/local/go #gosetup
GOPATH=/home/deepin/go #gosetup
/usr/local/go/bin/go build -o /tmp/___go_build_main_go /home/deepin/go/test1/main.go #gosetup
/tmp/___go_build_main_go
[-3 0 2 2 12 23 43 234 234 435]
Process finished with the exit code 0

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号