python组合无重复三位数的实例
作者:Guo_Apple 时间:2021-11-18 03:59:13
# -*- coding: utf-8 -*-
# 简述:这里有四个数字,分别是:1、2、3、4
#提问:能组成多少个互不相同且无重复数字的三位数?各是多少?
def f(n):
list=[]
count=0
for i in range(1,n+1):
for j in range(1, n+1):
for k in range(1, n+1):
if i!=j and j!=k and i!=k:
list.append(i*100+j*10+k)
count=len(list)
print count
return list
if __name__=="__main__":
print f(4)
运行结果:
24
[123, 124, 132, 134, 142, 143, 213, 214, 231, 234, 241, 243, 312, 314, 321, 324, 341, 342, 412, 413, 421, 423, 431, 432]
来源:https://blog.csdn.net/Guo_Apple/article/details/68921861
标签:python,无重复,三位数
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
pytorch常用函数定义及resnet模型修改实例
2022-09-18 08:19:19
教你用python提取txt文件中的特定信息并写入Excel
2021-02-11 00:41:41
![](https://img.aspxhome.com/file/2023/2/107262_0s.png)
Typecho插件实现添加文章目录的方法详解
2023-05-25 07:19:04
从 msxml6.dll 中获取 DOMDocument 对象的方法与属性
2009-02-22 18:46:00
PyTorch安装与基本使用详解
2023-05-09 03:20:51
![](https://img.aspxhome.com/file/2023/5/92255_0s.png)
python二分查找算法的递归实现方法
2023-05-12 23:22:48
如何从Notes中读取数据?
2009-11-15 19:57:00
用python写PDF转换器的实现
2022-07-29 21:32:28
![](https://img.aspxhome.com/file/2023/1/87681_0s.png)
win10下Python3.6安装、配置以及pip安装包教程
2022-09-27 12:29:46
![](https://img.aspxhome.com/file/2023/3/101303_0s.png)
Javascript 利用 DOM 特性的两个小技巧
2009-02-28 14:07:00
python因子分析的实例
2021-12-29 18:20:44
![](https://img.aspxhome.com/file/2023/8/76738_0s.png)
8大措施帮你构筑Access安全防线
2010-03-11 14:38:00
SQL子查询全接触
2007-08-20 10:51:00
对python cv2批量灰度图片并保存的实例讲解
2022-06-11 18:21:36
使用python socket分发大文件的实现方法
2022-05-23 10:45:40
golang中defer的关键特性示例详解
2023-08-06 06:12:45
python面向对象之类的继承详解
2022-03-20 18:22:22
![](https://img.aspxhome.com/file/2023/6/82756_0s.png)
Python Opencv基于透视变换的图像矫正
2022-03-13 16:47:14
Python3列表内置方法大全及示例代码小结
2022-09-23 01:39:21
![](https://img.aspxhome.com/file/2023/1/72141_0s.jpg)
JS分割字符串并放入数组的函数
2023-08-05 15:31:03