菜鸟问题:这个程序放在VC里面需要改什么东西,
#include <math.h>
#include <stdlib.h>
#include <iostream.h>
const double epsilon=1.e-5;//convergence condition
const long N=10000;//Loop times
double f(double x)
{
double temp;
//To Add: temp=Your Function
temp=2.*x*x*x-5*x*x+34.*x+54.;
return temp;
}
double Newton(double a, double b, double
(*pf)(double))
{
double x0=0.;
double x1=0.;
double x2=1.;
int counter=0;
while(fabs(x2-x1)>epsilon&&counter<N)
{
x0=x1;
x1=x2;
x2=x1-pf(x1)*(x1-x0)/(f(x1)-f(x0));
counter++;
}
if(counter==N)
{
cout<<"Sorry, I can't solve it!"<<endl;
exit(0);
}
else
return x2;
}
void main(void)
{
cout<<Newton(1,100,f)<<endl;
cout<<f(Newton(1,100,f))<<endl;
}
我想用消息框显示结果