快速排序+随机快排

#-*- coding:utf-8 -*- def quickSort(low,hight,list): if (low>hight): return j=hight i=low temp=list[low] while i!=j: while list[j]>=temp and i<j: j-=1 while list[i]<=temp and i<j: i+=1 if i<j: k=list[i] list[i]=list[j] list[j]=k list[low]=list[i] list[i]=temp print list quickSort(low,i-1,list) quickSort(i+1,hight,list) return low=0
list=[5,8,9,2,1,9,6,5]
hight=len(list)-1

quickSort(low,hight,list)

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zgdgzf.html