def perm(list,stack):
if not list:
print(stack) # 到树的最后,输出结果
else: # 没有到树的叶子节点的时候,使用递归继续往下找。
for i in range(len(list)):
stack.append(list[i])
del list[i]
perm(list,stack)
list.insert(i,stack.pop())
list=[1,2,3]
stack=[]
perm(list,stack)
算法--使用递归求解全排列(Python)
猜你喜欢
转载自blog.csdn.net/Dooonald/article/details/82591240
今日推荐
周排行