GO语言实现冒泡排序
package main import ( "fmt" )
func BubbleSort(num []int) {
for i := 0; i < len(num); i++ {
for j := 1; j < len(num) - i; j++ {
if (num[j] < num[j-1]) {
num[j], num[j - 1] = num[j - 1], num[j]
}
}
}
}
func main() {
a := [...] int {1,5684,25,487,74,2,54894,51,65874,51,65,478}
BubbleSort(a[:])
fmt.Println(a)
}