#include "stdafx.h"
#include <iostream>
double betsy(int);
double pam(int);
int main()
{
using namespace std;
int code;
cout<<"how mann lines of code do you need? ";
cin>>code;
cout<<"here's betsy's estimate:\n";
estimate(code, betsy);
cout<<"here pam estimate:\n";
estimate(code, pam);
return 0;
}
double betsy(int lns)
{
return 0.05*lns;
}
double pam(int lns)
{
return 0.03*lns + 0.0004 *lns*lns;
}
void estimate(int lines, double (*pf)(int))
{
using namespace std;
cout<<lines<<" lines will take ";
cout<<(*pf)(lines)<<" hour(s)\n";
}
函数指针
最新推荐文章于 2024-04-29 23:50:53 发布