一、go
go的冒泡排序
package main import "fmt" func main() { a:=[8]int{3,42,6,7,58,5,44,78} num:=len(a) for i :=0;i<num;i++{ for j:=i+1;j<num;j++{ if a[i]<a[j] { tem:=a[i] a[i]=a[j] a[j]=tem } } } fmt.Println(a) } --------------------------------------------------------------- [78 58 44 42 7 6 5 3]
有疑问加站长微信联系(非本文作者)