编写程序-不相同的三位数和四位数

#不同的四位数
count=0
list=[1,2,3,4,5]
for i in list:
    for j in list:
        for y in list:
            for s in list:
                if i!=j and j!=y and y!=s and s!=i:
                    count=count+1
                print(str(i)+str(j)+str(y)+str(s), end="\t")
print("一共有多少种{}方案".format(count))
#不同的三位数
count=0
list=[1,2,3,4,5]
for i in list:
    for j in list:
        for y in list:
                if i!=j and j!=y and y!=i:
                    count=count+1
                print(str(i)+str(j)+str(y), end="\t")
print("一共有多少种{}方案".format(count))

猜你喜欢

转载自blog.csdn.net/m0_62491934/article/details/121305668