游客 Signup | Login
中文 | En

3814 - 第三章:if选择结构《练习5:输出三个数最大者》

输入三个实数(double)a、b、c,输出它们中的最大值(保留两位小数)。

Input

Output

Examples

Input

2 5 4

Output

5.00

Solution C

#include <stdio.h>

int main(void) {
	double a, b, c;
	scanf("%lf%lf%lf", &a, &b, &c);
	if(a > b && a > c)
		printf("%.2lf", a);
	if(b > a && b > c)
		printf("%.2lf", b);
	else
		printf("%.2lf", c);
	return 0;
}

Solution C++

#include<cstdio>
using namespace std;
int main()
{
	double a,b,c;
	scanf("%lf%lf%lf",&a,&b,&c);
	if(a>=b&&a>=c)
	{
		printf("%.2lf",a);
	}
	else if(b>=a&&b>=c)
	{
		printf("%.2lf",b);
	}
	else
	{
		printf("%.2lf",c);
	}
	return 0;
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题