题解 | #参数解析#
输入整型数组和排序标识,对其元素按照升序或降序进行排序
http://www.nowcoder.com/practice/dd0c6b26c9e541f5b935047ff4156309
# 写一个冒泡搞定
def maopao(lenth, list1, flag): for i in range(lenth): for j in range(lenth-i-1): if flag == '0': if list1[j] > list1[j+1]: list1[j], list1[j+1] = list1[j+1], list1[j] else: if list1[j] < list1[j+1]: list1[j], list1[j+1] = list1[j+1], list1[j] return [str(x) for x in list1] res = [] while True: try: a = int(input()) b = [int(x) for x in input().split()] # 列表 c = input() result = maopao(a, b, c) res.append(result) except EOFError: for x in res: print(' '.join(x)) break