当前位置:网站首页>Blue Bridge Cup -- sequence sequencing problem
Blue Bridge Cup -- sequence sequencing problem
2022-04-21 07:39:00 【Qian & Shou】
1. Problem description
Given a length of n Sequence of numbers , Arrange the sequence in descending order .1<=n<=200
2. Subject requirements
The first line is an integer n.
The second line contains n It's an integer , Is the number to be sorted , The absolute value of each integer is less than 10000.
Output one line , Output the sorted sequence in descending order .
The time limit :1.0s Memory limit :512.0MB
for example : Input 5
8 6 5 9 1
Output 1 5 6 8 9
3. My answer
lst1=[]
n=int(input())
lst2=input().split(' ')
for i in range(n):
lst1.append(int(lst2[i]))
lst1.sort()
for num in lst1:
print(num,end=' ')
sort() Function to sort the original list , The default is ascending
For specific usage, please refer to : Novice tutorial ——python list sort()
4. matters needing attention
lst1=[]
n=int(input())
lst2=map(int,input().split())
for i in range(n):
lst1.append(lst2[i])
lst1.sort()
for num in lst1:
print(num,end=' ')
If the above code runs , There will be a running error :
TypeError: ‘map’ object is not subscriptable
indicate map() Function not subscript , So this question can't be used map() Function transform data type .
版权声明
本文为[Qian & Shou]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210624476355.html
边栏推荐
猜你喜欢

音频功率放大器,纳芯威功放,NS4165B单通道5.3W AB\D类功放,主要替换智浦芯的CS8571、CS8871、CS5218海栎创的HAA2018

光华芯音频Codec大全CJC4344、CJC8988、CJC5340、CJC6811光华芯音频codec、CJC4344、CJC8988、替换顺芯ES8388、替换cs5340

用友OA漏洞复现手册

Log4j远程代码执行漏洞验证

Steps of connecting hbuilderx to nocturnal simulator

蓝桥杯——十六进制转八进制

宏晶微MS9288、模拟RGB(VGA)转HDMI,HDMI发射器,音频解码器,内置MCU

RTSP未授权访问

任意用户注册&任意用户密码修改

时钟IC,INS5101A,I2C低功耗 RTC 实时时钟芯片,替换HYM8563,替换(NXP)PCF8563,TCS8563,I2C低功耗 RTC 实时时钟芯片
随机推荐
On balanced binary tree
JS different time format conversion
网上订餐系统数据库需求分析
File system structure analysis and data recovery
Word XML space character
thymleaf引擎中 checkbox的使用
2020-12-24
RTSP unauthorized access
Weak password-20211221
[seeing is not true - bugku CTF]
BGP 邻居
有关imap-tools模块实现邮件移动的问题
用友OA漏洞复现手册
CS5518,MIPI转双路LVDS,替换:国腾的GM8775,东芝TC358775,双路LVDS,国产完美替换,DSI 转双通道 LVDS,,LVDS 时钟频率最高154MHz,1920 x1200
Solving 0 / 1 knapsack problem by dynamic programming
蕊源:RY3408、RY3410主要替换:矽力杰SY8088、SY8089,TI的TLV62568、TLV62565芯源的MP2161、MP2128、MP2105
China Resources micro power amplifier cs3850eo, 2 × 40W class D audio power amplifier circuit, replacement: Zhipu core cs8673, tas5780 and tas5754 of Ti, domestic power amplifier
Mask + RGB for background subtraction
IGMP_华为
任意用户注册&任意用户密码修改