<每日一题>题目29:五个数字能组成多少互不重复的四位数

#有五个数字:1、2、3、4、5,能组成多少个互不相同且无重复数字的四位数?各是多少?
e =[]
for a in range(1,6):
	for b in range(1,6):
		for c in range(1,6):
			for d in range(1,6):
				if a!=b and a!=c and a!=d and b!=c and b!=d and c!=d:
					e.append(str(a)+str(b)+str(c)+str(d))
print("组成数量:%d" %len(e))
print(e)

  运行结果:

猜你喜欢

转载自www.cnblogs.com/shuimohei/p/10383047.html