游客 Signup | Login
中文 | En

2542 - [语言过关] 三数字排序

输入三个数实数,要求从小到大输出。

输入格式

只有一行分别为a,b,c,用空格隔开。

输出

输出为一行,共三个实数,用空格隔开。

样例输入

1.001 3.123 2.456

样例输出

1.001 2.456 3.123


Input

Output

Examples

Input


                

Output


                

Solution C

#include<stdio.h>
int main()
{
	double s[50];
	double t;
	int i;

	for (int j = 0; j < 3; j++)
	{
		scanf("%lf", &s[j]);
	}
	for (i = 0; i < 3; i++)
	{
		if (s[i-1] > s[i])
		{
			t = s[i-1];
			s[i-1] = s[i];
			s[i] = t;
		}
	}
	for (int j = 0; j < 3; j++)
	{
		printf("%.3lf ", s[j]);
	}
	printf("\n");
}

Solution C++

#include <cstdio>
#include <cstdlib>
int swap(float &a,float &b){
  float t;
  if (a>b) { t=a;a=b;b=t;}
}
int main(){
float a, b, c, t;
  scanf("%f%f%f", &a, &b, &c);
  if(a > b) swap(a,b);
  if(a > c) swap(a,c);
  if(b > c) swap(b,c);
  printf("%.3f %.3f %.3f\n", a, b, c);
  //system("pause");
  return 0;
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题