C++ primer plus第六版课后编程练习答案:7.1

#define  _CRT_SECURE_NO_WARNINGS 
#include 

double harmonic_average(double x, double y);

int main()
{
    double x, y;

    std::cout << "Please enter two numbers(0 to quit): ";
    std::cin >> x >> y;

    while (x*y != 0)
    {
        double h_average = harmonic_average(x, y);
        std::cout << "The harmonic_average is: " << h_average << std::endl;
        std::cout << "Please enter two numbers(0 to quit): ";
        std::cin >> x >> y;
    }
    std::cout << "Bye~!" << std::endl;
    return 0;
}

double harmonic_average(double x, double y)
{
    double h_average;
    return h_average = 2.0*x*y / (x + y);
}

你可能感兴趣的:(C++,primer,plus第六版课后编程练习)