牛顿迭代法开平方
double mysqrt(double x)
{
if (x == 1 || x == 0)
return x;
double temp = x / 2;
while (1)
{
double a = temp;
temp = (temp + x / 2) / 2;
if (a - temp < 0.001&&a>temp)
return temp;
}
}
牛顿迭代法开平方
double mysqrt(double x)
{
if (x == 1 || x == 0)
return x;
double temp = x / 2;
while (1)
{
double a = temp;
temp = (temp + x / 2) / 2;
if (a - temp < 0.001&&a>temp)
return temp;
}
}