count = 0
grade = []
for x in range (1,5):
for y in range (1,5):
for d in range (1,5):
if ((x != y) and ((y != d) and (x != d))):
count += 1
n = str(x) ; b = str(y) ; a = str(d)
grade.append(list(zip(n,b,a)))
print('内容如下:')
for each in grade:
print(each)
print ('排列个数为:%d' % count )
print(grade)
运行内容:
内容如下:
[('1', '2', '3')]
[('1', '2', '4')]
[('1', '3', '2')]
[('1', '3', '4')]
[('1', '4', '2')]
[('1', '4', '3')]
[('2', '1', '3')]
[('2', '1', '4')]
[('2', '3', '1')]
[('2', '3', '4')]
[('2', '4', '1')]
[('2', '4', '3')]
[('3', '1', '2')]
[('3', '1', '4')]
[('3', '2', '1')]
[('3', '2', '4')]
[('3', '4', '1')]
[('3', '4', '2')]
[('4', '1', '2')]
[('4', '1', '3')]
[('4', '2', '1')]
[('4', '2', '3')]
[('4', '3', '1')]
[('4', '3', '2')]
排列个数为:24
[[('1', '2', '3')], [('1', '2', '4')], [('1', '3', '2')], [('1', '3', '4')], [('1', '4', '2')], [('1', '4', '3')], [('2', '1', '3')], [('2', '1', '4')], [('2', '3', '1')], [('2', '3', '4')], [('2', '4', '1')], [('2', '4', '3')], [('3', '1', '2')], [('3', '1', '4')], [('3', '2', '1')], [('3', '2', '4')], [('3', '4', '1')], [('3', '4', '2')], [('4', '1', '2')], [('4', '1', '3')], [('4', '2', '1')], [('4', '2', '3')], [('4', '3', '1')], [('4', '3', '2')]]
|