BC122 有序序列判断
思路:
step1:输入数字和数字串;
step2:用ls2存正序,ls3存倒序,正序排列使用.sort(),倒序使用.reverse();
step3:比较打印;
代码如下:
n = input()
ls = list(map(int,input().split(' ')))
ls2 = sorted(ls)
ls3 = sorted(ls)
ls3.reverse()
if ls == ls2 or ls == ls3:
print('sorted')
else:
print('unsorted')