pytyon 带有重复的全排列

来源:互联网 时间:1970-01-01


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):
  dfs(cur, i)
  print
dfs(0, start) 

相关阅读:
Top