02883: Checking order
http://cs101.openjudge.cn/practice/02883/
输入长度为5的数字串,检查是否是按从小到大的顺序排列,如果是,输出Yes;否则,输出No,并输出从小到大排序后的结果。
输入
长度为5的一串数字;
输出
判断结果及排序后的结果。
样例输入
1 3 5 7 9
5 3 44 7 3
1 1 2 2 3样例输出
Yes
No 3 3 5 7 44
Yespython
while True:
try:
# 读取输入的长度为 5 的数字串
nums = list(map(int, input().split()))
# 复制一份原始列表用于排序
sorted_nums = sorted(nums)
if nums == sorted_nums:
print("Yes")
else:
print("No", " ".join(map(str, sorted_nums)))
except EOFError:
break