pytyon 带有重复的全排列
程序员文章站
2022-06-25 14:20:25
复制代码 代码如下:from sys import argvscript, start, end = argvvis = [0, 0, 0, 0, 0, 0, 0, 0,...
复制代码 代码如下:
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)
dfs(0, start)
上一篇: PHP延迟静态绑定的深入讲解