使用golang写一个冒泡排序
func bubbleSort(arr []int) { n := len(arr)
for i := 0; i < n-1; i++ {
for j := 0; j < n-i-1; j++ {
if arr[j] > arr[j+1] {
arr[j], arr[j+1] = arr[j+1], arr[j]
}
}
}
}
原文地址: https://www.cveoy.top/t/topic/bao5 著作权归作者所有。请勿转载和采集!