游客 Signup | Login
中文 | En

1333 - C语言程序设计教程(第三版)课后习题9.8

分别用函数和带参的宏,从三个数中找出最大的数。

Input

3个实数

Output

最大的数,输出两遍,先用函数,再用宏。保留3位小数。

Examples

Input

1 2 3

Output

3.000
3.000

Solution C++

#include<iostream>
#include<stdio.h>
#define	MAX(a,b,c) ((a>b?a:b)>c?(a>b?a:b):c)
using namespace std;
double max(double a,double b,double c)
{
	return (a>b?a:b)>c?(a>b?a:b):c;
}
int main()
{
	double a,b,c;
	cin>>a>>b>>c;
	printf("%.3lf\n",max(a,b,c));
	printf("%.3lf\n",MAX(a,b,c));
	return 0;
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题