while True:
try:
a = input().strip()
b = [int(x) for x in input().split()]
c = input().strip()
if len(b) > int(a): break
else:
if int(c) == 0:
print(" ".join(map(str,sorted(b))))
elif int(c) == 1:
print(" ".join(map(str,sorted(b)[::-1])))
else:
break
except:
break
tips:
不想这么写sorted(b)[::-1] ,可以考虑sorted(b,reverse=1) (0为默认正序,1为倒序)

京公网安备 11010502036488号