代码:from random import randintdef quick_sort(lst,first,last): low=first high=last if first<last: mid_value=lst[first] while low<high: while low<high and lst[high]>=mid_value: high=high-1 lst[low]=lst[high] while low<high and lst[low]<=mid_value: low=low+1 lst[high]=lst[low] lst[low]=mid_value quick_sort(lst,first,low-1) quick_sort(lst,low+1,last) return lstl=[]for i in range(10): l.append(randint(1,100))print(l)print(l,0,len(l-1))运行结果:
[89, 86, 5, 76, 12, 13, 20, 57, 20, 18]
[5, 12, 13, 18, 20, 20, 57, 76, 86, 89]