本帖最后由 健康的西西弗斯 于 2022-5-31 22:19 编辑
for i1 in range(1,5):
for i2 in range(1,5):
for i3 in range(1,5):
for i4 in range(1,5):
if i1!=i2 and i1!=i3 and i1!=i4 and i2!=i3 and i2!=i4 and i3!=i4:
print(i1,i2,i3,i4)
结果:
1 2 3 4
1 2 4 3
1 3 2 4
1 3 4 2
1 4 2 3
1 4 3 2
2 1 3 4
2 1 4 3
2 3 1 4
2 3 4 1
2 4 1 3
2 4 3 1
3 1 2 4
3 1 4 2
3 2 1 4
3 2 4 1
3 4 1 2
3 4 2 1
4 1 2 3
4 1 3 2
4 2 1 3
4 2 3 1
4 3 1 2
4 3 2 1
a=[1,2,3,4]
for i1 in a:
for i2 in a:
for i3 in a:
for i4 in a:
if i1!=i2 and i1!=i3 and i1!=i4 and i2!=i3 and i2!=i4 and i3!=i4:
print(i1,i2,i3,i4)