python 四个不重复的 四位数 python有四个数字: 1、2、3、4, 5,能组成多少个...

python \u67091\uff0c2\uff0c3\uff0c4\u4e2a\u6570\u5b57\uff0c\u80fd\u7ec4\u6210\u591a\u5c11\u4e2a\u4e92\u4e0d\u76f8\u540c\u4e14\u65e0\u91cd\u590d\u6570\u5b57\u7684\u4e09\u4f4d\u6570\uff1f\u90fd\u662f\u591a\u5c11

\u75281\uff0c2\uff0c3\uff0c4\u6570\u5b57\uff0c\u80fd\u7ec4\u621024\u4e2a\u4e92\u4e0d\u76f8\u540c\u4e14\u65e0\u91cd\u590d\u6570\u5b57\u7684\u4e09\u4f4d\u6570\uff0c\u5206\u522b\u4e3a\uff1a123,124,132,134,142,143,213,214,234,231,241,243,312,314,321,324,341,342,412,413,421,423,431,432\u3002

num = 0ls = [1, 2, 3, 4, 5]for i in ls:
for j in ls:
for p in ls:
if i == j or j == p or i == p:
continue
else:
num += 1print('\u80fd\u7ec4\u6210%d\u4e2a' % num)

for i in range(1,5):
    for j in range(1,5):
        for n in range(1,5):
            for k in range(1,5):
                if k != n and k != j and k!= i and n!= j and n!=i and j!=i:
                    print (i,j,n,k)


扩展阅读:python入门 ... python运行暂停 继续 ... python 双for循环判断重复 ... python 列表去重复 ... python 强制退出 ... python求不重复的随机数 ... python 跳出循环体 ... python随机抽题且不重复 ... python 结果一块表达 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网