
int main()
{
double n, x0, x1;
scanf("%lf",&n);
x0=n;
x1=1.0/2*(x0+n/x0);
while (fabs(x0-x1)>=1e-5)
{
x0=x1;
x1=1.0/2*(x0+n/x0);
}
printf("%f",x1);
}
欢迎分享,转载请注明来源:内存溢出

int main()
{
double n, x0, x1;
scanf("%lf",&n);
x0=n;
x1=1.0/2*(x0+n/x0);
while (fabs(x0-x1)>=1e-5)
{
x0=x1;
x1=1.0/2*(x0+n/x0);
}
printf("%f",x1);
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)