当前位置:网站首页>Title 37: sorting 10 numbers
Title 37: sorting 10 numbers
2022-06-12 18:16:00 【A little vegetable loving girl】
In the first solution , I'll arrange the data first , Reverse the line again , Because there are few sorted data at present , So there is no problem with this operation .
however , In fact, sorting is a waste of time . More economical , You can first store the results of the positive row in an array , Then reverse output it , You can get the inverted data . This operation is twice as fast as the first solution , save 50% Time for .
Code :
number_list = []
for i in range(1, 11):
number_i = int(input(f' Please enter the first {i} Number :'))
number_list.append(number_i)
number_list.sort()
print(f' The order from small to large is :{number_list}')
number_list.reverse()
print(f' The order from big to small is :{number_list}')Running results :

边栏推荐
- Summary of interview questions
- es7不使用父子和嵌套关系来实现一对多功能
- VirtualLab basic experiment tutorial -6 Blazed grating
- General differences between SQL server versions released by Microsoft in different periods so far, for reference
- Leetcode491 increasing subsequence
- js二分法
- JS judge palindromes
- DRM driven MMAP detailed explanation: (I) preliminary knowledge
- 01-复杂度
- A story on the cloud of the Centennial Olympic Games belonging to Alibaba cloud video cloud
猜你喜欢

A story on the cloud of the Centennial Olympic Games belonging to Alibaba cloud video cloud

LCD parameter interpretation and calculation

General differences between SQL server versions released by Microsoft in different periods so far, for reference

VirtualLab基礎實驗教程-4.單縫衍射

Gd32f4xx controls dgus variable display

机器学习系列(5):朴素贝叶斯

C语言学习——数据在内存中的存储

Introduction to service grid and istio - continued

C language learning -- data storage in memory

Gospel of audio and video developers, rapid integration of AI dubbing capability
随机推荐
First principles of enterprise architecture
Summary of static memory allocation and dynamic memory allocation
Lenovo responded that there are too many and too messy notebooks: it is now the product adjustment period and will be divided into three series of digital /air/ pro in the future
Introduction to service grid and istio - continued
Stream流注意点
leetcode 300. 最长递增子序列
Write a select based concurrent server
同花顺能开户吗,同花顺在APP上可以直接开通券商安全吗
Schéma de cristallisation différentielle active et différence entre LV - PECL, LVDS et hcsl
Relationship between resolution and line field synchronization signal
用好IDE,研发效能提速100%
js判断回文数
TypeScript常用类型(一)
Make good use of IDE, speed up R & D efficiency by 100%
"Big fat • small lesson" - talk about big file segmentation and breakpoint sequel
Nixos 22.05 installation process record
VirtualLab基礎實驗教程-4.單縫衍射
企业架构的第一性原理
MYSQL:Expression #4 of SELECT list is not in GROUP BY clause and contains nonaggregated column
Vant3+ts encapsulates uploader upload image component