题目描述
分别用函数和带参的宏,从三个数中找出最大的数。
输入
3个实数
输出
最大的数,输出两遍,先用函数,再用宏。 保留3位小数。
样例输入
1 2 3
样例输出
3.000
3.000
#include<stdio.h>
void max(int *a,int *b,int *c )
{ double temp;
if(*a>*b) temp=*a;
else temp=*b;
if(*c>temp) temp=*c;
printf("%0.3f\n",temp);
}
#define max_1(a, b, c) {if(a>b) temp=a;else temp=b;if(c>temp) temp=c; }
int main()
{
int a[3];
int i;
double temp;
for(i=0;i<3;i++)
{
scanf("%d",&a[i]);
}
max(&a[0],&a[1],&a[2]);
max_1(a[0],a[1],a[2]);
printf("%0.3f",temp);
return 0;
}