__author__ = "yang xin"array=[]def quickSort(left,right): if left > right: return temp = array[left] i = left j = right while i < j: if array[j] >= te ...
__author__ = "yang xin"
array=[]
def quickSort(left,right):
if left > right:
return
temp = array[left]
i = left
j = right
while i < j:
if array[j] >= temp and i<j:
#if j-1>=left:
j -= 1
if array[i] <= temp and i<j:
# if i+1<right:
i += 1
if i < j:
tag = array[i]
array[i] = array[j]
array[j] = tag
array[left] = array[i]
array[i]=temp;
quickSort(left,i-1)
if i+1<right:
quickSort(i+1,right)
return
n=input("請輸入排序數字的個數:")
m=int(n)
for i in range(m):
array.append(int(input()))
quickSort(0,m-1)#特別註意第二個參數的問題,因為在range裡面是做閉右開,防止list index out of range錯誤,在這控制他為左閉右閉
print(array)