输入4个整数a,b,c,d,编写程序,将它们按从大到小的顺序输出
发布网友
发布时间:2022-05-03 09:44
我来回答
共1个回答
热心网友
时间:2023-10-19 17:18
#include"stdio.h"
void main()
{
int a, b, c, d, t;
printf("输入四个整数");
scanf("%d %d %d %d",&a,&b,&c,&d);
if(a < b)
{
t = a; a = b; b = t;
}
if(a < c )
{
t = a; a = c; c = t;
}
if (a < d)
{
t = a; a = d; d = t;
}
if( b < c)
{
t = b; b = c; c = t;
}
if (b < d)
{
t = b; b = d; d = t;
}
if (c < d)
{
t = c; c = d; d = t;
}
printf("%d %d %d %d",a,b,c,d);
}
热心网友
时间:2023-10-19 17:18
#include"stdio.h"
void main()
{
int a, b, c, d, t;
printf("输入四个整数");
scanf("%d %d %d %d",&a,&b,&c,&d);
if(a < b)
{
t = a; a = b; b = t;
}
if(a < c )
{
t = a; a = c; c = t;
}
if (a < d)
{
t = a; a = d; d = t;
}
if( b < c)
{
t = b; b = c; c = t;
}
if (b < d)
{
t = b; b = d; d = t;
}
if (c < d)
{
t = c; c = d; d = t;
}
printf("%d %d %d %d",a,b,c,d);
}
热心网友
时间:2023-10-19 17:18
#include"stdio.h"
void main()
{
int a, b, c, d, t;
printf("输入四个整数");
scanf("%d %d %d %d",&a,&b,&c,&d);
if(a < b)
{
t = a; a = b; b = t;
}
if(a < c )
{
t = a; a = c; c = t;
}
if (a < d)
{
t = a; a = d; d = t;
}
if( b < c)
{
t = b; b = c; c = t;
}
if (b < d)
{
t = b; b = d; d = t;
}
if (c < d)
{
t = c; c = d; d = t;
}
printf("%d %d %d %d",a,b,c,d);
}