c++ 读取一行的2个数

#include <iostream>
using namespace std;
double harmonicMean(double x, double y);

int main() {
	double x, y;
	while (cin >> x >> y) { // 这一步是读取一行的两个数
		if (0 == x || 0 == y) break;
		cout << harmonicMean(x, y) << endl;
	}
	return 0;
}

double harmonicMean(double x, double y) {
	return 2.0 * x * y / (x + y);
}

  

posted @ 2018-09-27 23:14  ranwuer  阅读(1412)  评论(0编辑  收藏  举报