游客 Signup | Login
中文 | En

1140 - C语言5.2

读入3个实数,按照代数值由小到大的顺序输出这3个数。

Input

3个用空格隔开的实数。

Output

按由小到大的顺序输出这3个实数,用空格隔开,并保留两位小数。

请注意行尾输出换行。

Examples

Input

12.51 8.26 11.39

Output

8.26 11.39 12.51

Solution C

#include<stdio.h>
int main(){
int i,j;
	double a[3],temp;
	scanf("%lf %lf %lf",&a[0],&a[1],&a[2]);
	for (i=0;i<2;i++)
		  for (j=i+1;j<3;j++)
			if (a[i]>a[j])
			{
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
for (i=0;i<2;i++)
  printf("%.2lf ",a[i]);
printf("%.2lf",a[i]);
printf("\n");
return 0;
}

Solution C++

#include <stdio.h>
int main() {
	float a, b, c, t;
	scanf("%f %f %f", &a, &b, &c);
	if (a > b) {
		t = a; a = b; b = t;
	}
	if (a > c) {
		t = a; a = c; c = t;
	}
	if (b > c) {
		t = b; b = c; c = t;
	}
	printf("%.2f %.2f %.2f\n", a, b, c);
	return 0;
}

Time Limit 1 second
Memory Limit 32 MB
Discuss Stats
上一题 下一题