请教有关用牛顿迭代法求平方根的问题
#include <stdio.h>#include <math.h>
int main(void)
{
double x, average;
double y = 1.0f;
double judge = 0.00001f;
printf("Enter a positive number: ");
scanf("%lf", &x);
do {
average = (y + (x / y))/2;
y = average;
} while (fabs(y - average) > judge * y);
printf("Square_root: %lf", y);
return 0;
}
我觉得应该是循环能力算法出了问题,但是不知道该怎么改?求问各路大神....