python小程序(2)#输入三个整数,将这三个数由小到大输出

python小程序(2)#输入三个整数,将这三个数由小到大输出
思路:
1.先将a,b两个数做比较,并将较大的放在第一的位置,较小的放在第二的位置。
2.再将c分别与第一的数与第二的数作比较,这里分了三种情况:

  1. c最大,将之前第二大的数放在第三位,之前第一大的数放在第二位,c放在第一位
  2. c比第一位的小,比第二位的大,将之前第二位的数放在第三位,c放在第二位
  3. c最小,c放在第三位,其他不变
a=int(input('Please input the first number:'))
b=int(input('Please input the second number:'))
c=int(input('Please input the second number:'))
if a>b:
    first=a
    second=b
else:
     first=b
     second=a
if first<c:
    third=second
    second=first
    first=c
elif first>c and c>second:
    third=second
    second=c
elif c<second:
    third=c

print('first number:',third)
print('second number:',second)
print('third number:',first)
    原文作者:我是最酷的栗子啊
    原文地址: https://blog.csdn.net/Angel_Emma/article/details/100186906
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞