下述程序用牛顿迭代法求方程:f(x)=x^2-a=0的正根.a>0,x0初值取1,解的精度为10^-5,请填空
doubleroot(double,double,double);voidmain(){intflag=1;doublea;while(flag){scanf("%lf"...
double root(double,double,double);
void main()
{
int flag=1;double a;
while(flag)
{
scanf("%lf",&a);
if(a>__)
flag=0;
}
printf("root=%lf\n",root(a,1,1.e-5));
}
double root(double a,double x1,double eps)
{
double x0;
do
{
x0=x1;
x1=__;
}
while(fabs(x1-x0)>=1e-5);
return x1;
} 展开
void main()
{
int flag=1;double a;
while(flag)
{
scanf("%lf",&a);
if(a>__)
flag=0;
}
printf("root=%lf\n",root(a,1,1.e-5));
}
double root(double a,double x1,double eps)
{
double x0;
do
{
x0=x1;
x1=__;
}
while(fabs(x1-x0)>=1e-5);
return x1;
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询