NEUQ1055譚浩強C語言(第三版)習題6.11

//迭代公式不是很理解,寫出來算了。。

#include <stdio.h>
#include <math.h>
int main()
{
    double x0,x1;
    int a;
    scanf("%d",&a);
    x0=a/2;
    x1=(x0+a/x0)/2;
    while(fabs(x0-x1)>=1e-5)
    {
        x0=x1;
        x1=(x0+a/x0)/2;
    }
    printf("%.3lf",x1);
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章