Question C: Example Questions 4-3 Switch 3 real values and output in order
Time limit: 1 SEC memory limit: 12 MB
Question description
Enter 3 real numbers A, B, C from the keyboard. By exchanging comparison, the minimum value is stored in variable A, the maximum value is stored in variable C, the middle value is stored in the variable B, and the order from small to large from small to large Output these three numbers A, B, C.
At the end of the output.
input
Input three real numbers separated by spaces
output
Output these three real numbers in the order from small to large, separate in the middle with spaces, the minimum value is the front, and the maximum value is behind. Stay 2 decimal numbers after the decimal point.
Pay attention to the end of the end.
Sample input
3 7 1
Sample output
1.00 3.00 7.00
Summary of Experience
Simple comparative problem ~~
AC code
#include <cstdio>
int main()
{
double a,b,c;
scanf("%lf %lf %lf",&a,&b,&c);
if(a>b)
{
if(b>c)
{
printf("%.2f %.2f %.2f\n",c,b,a);
}
else
{
if(a>c)
printf("%.2f %.2f %.2f\n",b,c,a);
else
printf("%.2f %.2f %.2f\n",b,a,c);
}
}
else
{
if(b>c)
{
if(a>c)
printf("%.2f %.2f %.2f\n",c,a,b);
else
printf("%.2f %.2f %.2f\n",a,c,b);
}
else
{
printf("%.2f %.2f %.2f\n",a,b,c);
}
}
return 0;
}