当前位置:网站首页>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 static memory allocation and dynamic memory allocation
- 小程序+App,低成本获客及活跃的一种技术组合思路
- Gospel of audio and video developers, rapid integration of AI dubbing capability
- Lightweight and convenient small program to app technology solution to realize interconnection with wechat / traffic app
- JS中的字符串(含leetcode例题)<持续更新~>
- Overall flow chart of kernel interrupt
- Use applet to quickly generate app in seven steps
- Resttemplateconfig configuration print request response log under soringboot
- 01-复杂度
- USB to serial port - serial port driver type
猜你喜欢

es7不使用父子和嵌套关系来实现一对多功能

PHP:Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocat

TypeScript常用类型(一)

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

Introduction to service grid and istio - continued

C language practice (4) -- multiplication and division of large numbers

USB转串口那些事儿—最大峰值串口波特率VS连续通信最高波特率

Gd32f4xx controls dgus variable display

C language learning -- data storage in memory

有源差分晶振原理圖以及LV-PECL、LVDS、HCSL區別
随机推荐
USB转串口那些事儿—串口驱动类型
ftrace
About datasets
低代码平台调研结果
Stream流注意点
USB转串口那些事儿—最大峰值串口波特率VS连续通信最高波特率
Applet and app are owned at the same time? A technical scheme with both
es7不使用父子和嵌套关系来实现一对多功能
LCD parameter interpretation and calculation
TypeScript常用类型(一)
Leetcode491 increasing subsequence
Schéma de cristallisation différentielle active et différence entre LV - PECL, LVDS et hcsl
MySQL learning notes
Explanation of core interrupt of Godson processor
Random talk about redis source code 90
Section qemu+gdb
Vant3+ts encapsulates uploader upload image component
General differences between SQL server versions released by Microsoft in different periods so far, for reference
JS quick sort
First principles of enterprise architecture