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); }