游客 Signup | Login
中文 | En

3148 - 习题2-4-3 三个数排序输出

输入3个整数a、b、c,按从小到大的顺序输出。

Input

输入包含一行,包含三个用空格隔开的整数。

Output

请按从小到大的顺序输出读入的三个数。请注意行尾输出换行。

Examples

Input

18 11 34

Output

11 18 34

Solution C

#include<stdio.h>
void main()
{
	int a,b,c,temp=0;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b) {temp=a;a=b;b=temp;}
	if(a>c){temp=a;a=c;c=temp;}
	if(b>c){temp=b;b=c;c=temp;}
	printf("%d %d %d\n",a,b,c);
}

Solution C++

#include<stdio.h>
int main()
{
	int a,b,c,t,m,n;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b)
	{
	   t=a;
	   a=b;
	   b=t;
    }
	   if(a<c)
	   {
	     m=a;
	     a=c;
	     c=m;
	   }
	     if(b<c)
	     {
	       n=b;
	       b=c;
	       c=n;
	     }
	printf("%d %d %d",c,b,a);
	return 0;
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题