Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
22 lines (15 loc) · 681 Bytes

File metadata and controls

22 lines (15 loc) · 681 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# -*- coding:utf-8 -*-
__author__ = 'gjw'
__time__ = '2018/1/3 0003 上午 10:07'
# 题目:有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少?
# 程序分析:可填在百位、十位、个位的数字都是1、2、3、4。组成所有的排列后再去 掉不满足条件的排列。
# 1.基础版
for i in range(1, 5):
for j in range(1, 5):
for k in range(1, 5):
if (i != k) and (i != j) and (j != k):
print(i, j, k)
# 2.列表解析
l_num = [1, 2, 3, 4]
ls = [i*100 + j *10 + k for i in l_num for j in l_num for k in l_num if(j != k and j != i and i != k)]
print(ls)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.