当前位置:网站首页>实例037:排序
实例037:排序
2022-08-04 01:35:00 【懒笑翻】
题目:对10个数进行排序。
程序分析:同实例005。
代码:
方法一:
raw=[]
for i in range(10):
x=int(input('int%d: '%(i)))
raw.append(x)
for i in range(len(raw)):
for j in range(i,len(raw)):
if raw[i]>raw[j]:
raw[i],raw[j]=raw[j],raw[i]
print(raw)
"""
* @Author: xiaofang
* @Description:
学习中遇到问题没人解答?小编创建了一个Python学习交流QQ群,扫描文末QQ群二维码即可
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
"""
方法二:
raw = []
for i in range(10):
x = int(input('int%d: ' % (i)))
raw.append(x)
print(sorted(raw))
结果:
边栏推荐
- 持续投入商品研发,叮咚买菜赢在了供应链投入上
- Web APIs BOM- 操作浏览器:swiper 插件
- lombok注解@RequiredArgsConstructor的使用
- The idea of the diagram
- nodejs+express实现数据库mysql的访问,并展示数据到页面上
- jmeter distributed stress test
- Array_Sliding window | leecode brushing notes
- 一个项目的整体测试流程有哪几个阶段?测试方法有哪些?
- Quickly build a website with static files
- Variable string
猜你喜欢
this巩固训练,从两道执行题加深理解闭包与箭头函数中的this
循环绕过问题
typescript56 - generic interface
typescript50 - type specification between cross types and interfaces
typescript58 - generic classes
114. How to find the cause of Fiori Launchpad routing error by single-step debugging
typescript48-函数之间的类型兼容性
数组_滑动窗口 | leecode刷题笔记
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
The 600MHz band is here, will it be the new golden band?
随机推荐
GraphQL背后处理及执行过程是什么
阿里云技术专家邓青琳:云上跨可用区容灾和异地多活最佳实践
静态/动态代理模式
Is there any jdbc link to Youxuan database documentation and examples?
螺旋矩阵_数组 | leecode刷题笔记
boot issue
DDTL:远距离的域迁移学习
- heavy OpenCV 】 【 mapping
【虚拟化生态平台】虚拟化平台esxi挂载USB硬盘
typescript50-交叉类型和接口之间的类型说明
2022 China Computing Power Conference released the excellent results of "Innovation Pioneer"
nodejs安装及环境配置
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
typescript51 - basic use of generics
内网穿透-应用
如何用C语言代码实现商品管理系统开发
C # WPF equipment monitoring software (classic) - the next
nodejs+npm的安装与配置
敏捷交付的工程效能治理
Vant3 - click on the corresponding name name to jump to the next page corresponding to the location of the name of the TAB bar