输入4个整数,要求按由小到大的顺序输出

#include <stdio.h>
//
int main()
{
    float a,b,c,d,t;
    printf("请输入4个整数 ");
    scanf("%f%f%f%f",&a,&b,&c,&d);
    if(a>b)
    {
        t = a;
        a = b;
        b = t;
    } //a<b
    if(a>c)
    {
        t = a;
        a = c;
        c = t;
    }
    if(a>d)
    {
        t = a;
        a = d;
        d = t;
    }//使得a为最小
    if(b>c)
    {
        t = b;
        b = c;
        c = t;
    }
    if(b>d)
    {
        t = b;
        b = d;
        d = t;
    }//使得b第二小
    if(c>d)
    {
        t = c;
        c = d;
        d = t;
    }// 使得c第三小
    printf("%7.2f %7.2f %7.2f %7.2f",a,b,c,d);
    return 0;
}

原文地址:https://www.cnblogs.com/LiQingXin/p/12769070.html