package main
import "fmt"
func BubbleSort(sourceNum []int){
for i,_ := range sourceNum{
for ii,vv := range sourceNum {
if i == 0 || ii == 0{
continue
}else if sourceNum[ii-1] > vv {
sourceNum[ii-1],sourceNum[ii] = vv,sourceNum[ii-1]
}
}
}
fmt.Println(sourceNum)
}
func main(){
sourceNum := []int{0,1,2,2,5,8,6,9,3,8,0}
BubbleSort(sourceNum)
}
有疑问加站长微信联系(非本文作者))