[Go] 冒泡法排序Go语言版 →→→→→进入此内容的聊天室

来自 , 2019-08-20, 写在 Go, 查看 101 次.
URL http://www.code666.cn/view/6d8e4836
  1. func BubbleSort(nums []int) {
  2.     unsorted := true
  3.     for unsorted {
  4.         unsorted = false
  5.         for i := len(nums) - 1; i > 0; i-- {
  6.             if nums[i] < nums[i-1] {
  7.                 nums[i], nums[i-1] = nums[i-1], nums[i]
  8.                 unsorted = true
  9.             }  
  10.         }  
  11.     }  
  12. }
  13. //go/4623

回复 "冒泡法排序Go语言版"

这儿你可以回复上面这条便签

captcha