在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
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 Process finished with the exit code 0
|
请发表评论