题解 | #输入整型数组和排序标识,对其元素按照升降序排序#
输入整型数组和排序标识,对其元素按照升序或降序进行排序
https://www.nowcoder.com/practice/dd0c6b26c9e541f5b935047ff4156309
while True: try: n = int(input()) numbers = list(map(int, input().split(' '))) rev = int(input()) if rev == 0: numbers_sorted = sorted(numbers, reverse=False) result_list = [str(i) for i in numbers_sorted] result = ' '.join(result_list) print(result) elif rev == 1: numbers_sorted = sorted(numbers, reverse=True) result_list = [str(i) for i in numbers_sorted] result = ' '.join(result_list) print(result) else: break except: break