菜鸟问题:这个程序放在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;
}
我想用消息框显示结果
#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;
}
我想用消息框显示结果
...全文
相关推荐
just.build:AWS Elastic Beanstalk 的示例 Node.js 应用程序
只是.build AWS Elastic Beanstalk 的示例 Node.js 应用程序
codepipeline-helloworld:创建完整的AWS CodePipeline并自动部署到ElasticBeanstalk中的示例代码
codepipeline-helloworld 创建完整的AWS CodePipeline并自动部署到ElasticBeanstalk中的示例代码 有关更多信息,请在此处阅读中型帖子->
angularawsapp:角度 aws 应用程序
angularawsapp 角度 aws 应用程序
carryhome_node_api:随身携带API接口| 节点| EC2-AWS
npm run-script build npm run dev npm start
nodejs-ci-cd
nodejs-ci-cd


