python不带重复的全排列代码
时间:2020-10-04 14:44:38|栏目:Python代码|点击: 次
复制代码 代码如下:
from sys import argv
script, start, end = argv
vis = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
ans = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
def dfs(cur, m):
ans[cur] = m
if cur == int(end) - int(start) + 1:
for i in xrange(int(start), int(end) + 1):
print ans[i],
return
cur = cur + 1
for i in xrange(int(start), int(end) + 1):
if vis[i] == False:
vis[i] = True
dfs(cur, i)
vis[i] = False
for i in xrange(1, len(vis)):
vis[i] = False
dfs(0, start)
栏 目:Python代码
下一篇:Python插件机制实现详解
本文标题:python不带重复的全排列代码
本文地址:http://www.codeinn.net/misctech/6910.html