/*4.两数值的谐均值可以这样计算:首先对两数值的倒数取平均值,最后再取倒数。编写一个带有两个 double 参数的函数,计算这两个参数的谐均值。*/
#include<stdio.h>
#include<stdlib.h>
double average(double, double);
int main()
{
double a, b;
printf("Please input two numbers:");
scanf("%lf %lf", &a, &b);
printf("average is %lf\n", average(a, b));
system("pause");
return 0;
}
double average(double i, double j)
{
return 1.0 / ((1.0 / i + 1.0 / j) / 2);
}