标签:.cpp 练习题 input ISE turn str alc nbsp namespace
第7章
7.13-1调和平均数
//7.13-1 excise.cpp 调和平均数
#include <iostream>
double calculate(double a,double b);
using namespace std;
main()
{
double x,y,z;
cout<<"please input x and y value: ";
cin>>x>>y;
while(x!=0&&y!=0)
{
z=calculate(x,y);
cout<<"调和平均数是"<<z<<endl;
cout<<"please input x and y value again: ";
cin>>x>>y;
}
cout<<"输入的值不符合要求,退出";
return 0;
}
double calculate(double a,double b)
{
double z;
z=2.0*a*b/(a+b);
return z;
}
标签:.cpp 练习题 input ISE turn str alc nbsp namespace
原文地址:https://www.cnblogs.com/dongguolei/p/9359442.html