时间:2021-07-23 07:37:42 | 栏目:Golang | 点击:次
//冒泡排序 func mpSort(array []int) { for i:=0;i<len(array);i++ { for j:=0;j<len(array)-i-1;j++ { if array[j] > array[j+1] { array[j], array[j+1] = array[j+1], array[j] } } } } //快速排序 func quickSort(array []int, left int, right int) { if left < right { key := array[left] low := left high := right for low < high { for low < high && array[high] > key { high-- } array[low] = array[high] for low < high && array[low] < key { low++ } array[high] = array[low] } array[low] = key quickSort(array, left, low-1); quickSort(array, low+1, right); } }
以上所述就是本文的全部内容了,希望大家能够喜欢。