输入4个整数,要求按由小到大的顺序输出
作者:互联网
#include <stdio.h>
//
int main()
{
float a,b,c,d,t;
printf("请输入4个整数\n");
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;
}
标签:顺序,使得,整数,由小到大,7.2,f%,printf,输入 来源: https://www.cnblogs.com/LiQingXin/p/12769070.html