描述: 输入整型数组和排序标识,对其元素按照升序或降序进行排序
输入描述:
第一行输入数组元素个数
第二行输入待排序的数组,每个数用空格隔开
第三行输入一个整数0或1,0代表升序,1代表降序
示例1:
输入:
8
1 2 4 9 3 55 64 25
0
输出:
1 2 3 4 9 25 55 64
示例2:
输入:
5
1 2 3 4 5
1
输出:
5 4 3 2 1
n = int(input())
num = list(map(int,input().split()))
s = int(input())
if s == 0:
num.sort()
for i in num:
print(i,end=' ')
elif s == 1:
num.sort(reverse = True)
for i in num:
print(i,end=' ')