import random
def qsort(L):
if len(L)<=1:
return L
return (qsort([i for i in L[1:] if i<=L[0]])+L[0:1]+qsort([i for i in L[1:] if i>L[0]]))
li = []
for i in range(20):
li.append(random.randrange(10,100))
print(li)
print(sorted(li))
print(qsort(li))
递归排序
最新推荐文章于 2022-11-30 22:08:32 发布