from copy import copy
f = open('全排列.txt', 'w', encoding='utf-8')
count = 0
def func_all(num=0, ls=[], tag=3):
ls.append(num)
if len(ls)-1 == tag:
print(ls[1:], file=f)
global count
count += 1
return
for i in range(1, tag+1):
if i not in ls:
func_all(i, copy(ls),tag)
func_all(tag=2)
print(count)
网友评论