def run(n):
visit=[True for i in range(n)]
temp=["" for x in range(n)]
def dfs(position):
if position == len(arr):
print(temp)
return
for index, val in enumerate(arr):
if visit[index] == True:
temp[position] = arr[index]
visit[index] = False
dfs(position + 1)
visit[index] = True
arr = [chr(i) for i in range(97, 97+n)]
dfs(0)
run(4)
python实现全排列
最新推荐文章于 2024-06-12 08:53:02 发布