python输入三个整数,按照从小到大的顺序输出他们的值
时间: 2023-05-01 18:05:56 浏览: 71
输入三个整数x,y,z,请把这三个数由小到大输出
可以这样写:
a, b, c = input('请输入三个整数,以空格分隔:').split()
a, b, c = int(a), int(b), int(c)
if a <= b <= c:
print(a, b, c)
elif a <= c <= b:
print(a, c, b)
elif b <= a <= c:
print(b, a, c)
elif b <= c <= a:
print(b, c, a)
elif c <= a <= b:
print(c, a, b)
else:
print(c, b, a)
阅读全文