python标准算法实现数组全排列代码,python标准算法数组,#code from h


#code from http://www.byrx.net/codes/def Mideng(li):    if(type(li)!=list):        return    if(len(li)==1):        return [li]    result=[]    for i in range(0,len(li[:])):        bak=li[:]        head=bak.pop(i)  #head of the recursive-produced value        for j in Mideng(bak):            j.insert(0,head)            result.append(j)    return resultdef MM(n):    if(type(n)!=int or n<2):        return    return Mideng(list(range(1,n)))
                                调用方法
MM(6)

评论关闭