#include <iostream>
double calculate(double a,double b,double (*ptr)(double a,double b));
double add(double a,double b);
double div(double a,double b);
int main() {
using namespace std;
cout<<"Enter two double numbers:";
double a,b;
while(cin>>a>>b)
{
cout<<"Add is : "<<calculate(a,b,add)<<endl;
cout<<"Divided is : "<<calculate(a,b,div)<<endl;;
cout<<"Next pairs numbers:";
}
return 0;
}
double calculate(double a,double b,double (*ptr)(double a,double b))
{
return ptr(a,b);
}
double add(double a,double b)
{
return a+b;
}
double div(double a,double b)
{
return a/b;
}
C++primer plus 6th 第7章7.10编程答案
最新推荐文章于 2024-11-10 06:12:48 发布