python 递归和分治法小练习

def fzf(width, high):
    while width != high:
        if width > high:
            width -= high
        if high > width:
            high -= width
    return high


def sum1(L):
    print(L)
    if len(L)<=1:
        return L[0]
    else:
        return L.pop()+sum1(L)


def qsort(L):
    if len(L) < 2:
        return L
    else:
        zjz = L[0]
        less = [i for i in L[1:] if i<=zjz]
        more = [i for i in L[1:] if i>zjz]
        return qsort(less)+[zjz]+qsort(more)

 

你可能感兴趣的:(python 递归和分治法小练习)