import time
def QUILTSORT(a,b,c):
if(b<c):
x=a[c]
i=b
j=c
while(i<j):
while(i<j and a[i]<a[j]):
i+=1
tmp=a[i]
a[i]=a[j]
a[j]=tmp
while(i<j and a[i]<a[j]):
j-=1
tmp=a[i]
a[i]=a[j]
a[j]=tmp
QUILTSORT(a,b,i-1)
QUILTSORT(a,i+1,c)
k=input()
k=int(k)
a=[]
for i in range(0,k):
tmp=input()
tmp=int(tmp)
a.append(tmp)
QUILTSORT(a,0,k-1)
print(a)
time.sleep(10)
快速排序(随机抽样python实现)
于 2023-06-14 20:18:40 首次发布