Problem D: 三个数比较大小
Description
从键盘上输入0~100之间的三个数,按从小到大的顺序输出。
Input
输入只有一行,为三个整数。
Output
按从小到大输出这三个数。
Sample Input
15 10 20
Sample Output
10 15 20
HINT
用if语句判断各种情况可以解决这个问题。
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,b,c,d,e,f;
scanf("%d %d %d",&a,&b,&c);
if(a>b)
{ if(b>=c)
{d=a;e=b;f=c;} //if要用{}
else
{
if(a<=c)
{d=c;e=a;f=b;}
else
{d=a;e=c;f=b;}}
}
else
{ if(a>=c)
{d=b;e=a;f=c;}
else
{
if(b<=c)
{d=c;e=b;f=a;}
else
{d=b;e=c;f=a;}
}
}
printf("%d %d %d\n",f,e,d);
return 0;
}