1 """题目:有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少? 2 程序分析:可填在百位、十位、个位的数字都是1、2、3、4。组成所有的排列后再去掉不满足条件的排列。""" 3 # 三种实现方法 4 5 for i in range(1, 433): 6 i = str(i) 7 if len(i) == 3: 8 if i[1] not in ['0', '5', '6', '7', '8', '9'] and i[2] not in ['0', '5', '6', '7', '8', '9']: 9 if i[0] not in i[1] and i[0] not in i[2] and i[1] not in i[2]: 10 print(i) 11 12 for a in range(1, 5): 13 for b in range(1, 5): 14 for c in range(1, 5): 15 if a != b and a != c and b != c: 16 print(a, b, c) 17 18 list_num = [1, 2, 3, 4] 19 for i in list_num: 20 for j in list_num: 21 for k in list_num: 22 if j != i and k != j and k != i: 23 print(i*100+j*10+k)