下面是Python的代码实现:

a = float(input("请输入第1个实数:"))
b = float(input("请输入第2个实数:"))
c = float(input("请输入第3个实数:"))

if a <= b and a <= c:
    if b <= c:
        print("从小到大顺序为:",a,b,c)
    else:
        print("从小到大顺序为:",a,c,b)
elif b <= a and b <= c:
    if a <= c:
        print("从小到大顺序为:",b,a,c)
    else:
        print("从小到大顺序为:",b,c,a)
else:
    if a <= b:
        print("从小到大顺序为:",c,a,b)
    else:
        print("从小到大顺序为:",c,b,a)

这里使用了多重嵌套的if语句来实现从小到大排序的功能。首先判断三个数中哪个最小,然后再比较另外两个数的大小关系,最后按照从小到大的顺序输出这三个数。

编程实现:输入3个实数按从小到大顺序输出。

原文地址: https://www.cveoy.top/t/topic/bdLO 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录