计算调和平均数

来源:互联网 发布:树莓派gpio编程c语言 编辑:程序博客网 时间:2024/04/28 07:35
#include<iostream>
using namespace std;


double subdivide(const double x,const double y);


int main(void)
{
using namespace std;
double x, y;
cout << "Enter two numbers:";
while (cin >> x >> y && x&&y)
{
cout << "average = :" << subdivide(x, y) << endl;
cout << "Enter two numbers:";
}
cout << "ERROY!";
cin.get();
cin.get();
return 0;
}
double subdivide(const double x, const double y)
{
return 2.0*x*y / (x + y);
}
0 0