while True:
try:
a,b,c=input(),map(int,input().split()),input()
if c=='0':
print(" ".join(map(str,sorted(b))))
if c=='1':
print(" ".join(map(str,sorted(b,reverse=True))))
except:
break
本文介绍了一个简单的Python程序,该程序接收用户输入的一组数字,并根据用户的指令进行升序或降序排序。通过使用Python内置的sorted函数和reverse参数,程序能够灵活地调整排序方式。
while True:
try:
a,b,c=input(),map(int,input().split()),input()
if c=='0':
print(" ".join(map(str,sorted(b))))
if c=='1':
print(" ".join(map(str,sorted(b,reverse=True))))
except:
break
3万+

被折叠的 条评论
为什么被折叠?