pytyon 带有重复的全排列
程序员文章站
2022-03-18 18:47:11
复制代码 代码如下: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)
上一篇: Android 逐帧动画(Frame)
下一篇: ai怎么设计一碗米饭的插画效果?