1. 程式人生 > >python八大排序之-----希爾排序

python八大排序之-----希爾排序

def Shell_sort(L):
    step = len(L)//2
    while step > 0:
        for i in range(step,len(L)):
            while(i >= step and L[i] < L[i-step]):
                L[i],L[i-step] = L[i-step],L[i]
                i -= step
        step //= 2
    print(L)
L=[]
listone = input("請輸入你要排序的玩意兒:")
b = listone.split(',')
for v in b:
    c=int(v)
    L.append(c)
Shell_sort(L)