Python:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?

#!/usr/bin/env python
# coding:UTF-8


"""
@version: python3.x
@author:曹新健
@contact: [email protected]
@software: PyCharm
@file: 1223.py
@time: 2018/12/23 22:39
"""
'''
有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?
'''
count = 0
for hundreds in range(1,5):
    for decade in range(1,5):
        for units in range(1,5):
            if hundreds == decade or hundreds == units or decade == units:
                continue
            print("{}{}{}".format(hundreds,decade,units))
            count += 1

print(count)

猜你喜欢

转载自blog.csdn.net/caoxinjian423/article/details/85370439