def swap(a,first,second):
temp=a[first]
a[first]=a[second]
a[second]=temp
def quicksort(a,begin,end):
if begin>=end:
return
t=a[begin]
i=begin+1
j=end
while True:
while a[i]<=t and i<=end:
i=i+1
while a[j]>t:
j=j-1
if i>j:
break
swap(a,i,j)
swap(a,begin,j)
quicksort(a,begin,j-1)
quicksort(a,j+1,end)
a=[1,1,3,4,2,5,3,7,10]
quicksort(a,0,6)
print a
python写的快速排序
最新推荐文章于 2025-06-18 10:13:17 发布