不要沮丧,不必惊慌,做努力爬的蜗牛或坚持飞的笨鸟,我们试着长大,一路跌跌撞撞,然后遍体鳞伤。坚持着,总有一天,你会站在最亮的地方,活成自己曾经渴望的模样。
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] = Falsefor i in xrange(1, len(vis)):
vis[i] = False
dfs(0, start)
本文python不带重复的全排列代码到此结束。你有你的诗和远方,我有我的懒和嚣张。小编再次感谢大家对我们的支持!