题解 | #输入整型数组,对其元素按照升序或降序进行排序#
输入整型数组和排序标识,对其元素按照升序或降序进行排序
https://www.nowcoder.com/practice/dd0c6b26c9e541f5b935047ff4156309
import sys #for line in sys.stdin: # a = line.split() # print(int(a[0]) + int(a[1])) i=int(input()) s=input().split() func=lambda x: int(x) s=list(map(func,s)) j=input() for m in range(i-1): for n in range(i-m-1): if s[n]>s[n+1]: s[n],s[n+1]=s[n+1],s[n] func2=lambda x : str(x) s=list(map(func2,s)) if j=="0": print(" ".join(s)) else: print(" ".join(s[::-1]))