求一个正整数X的平方根Y,要求y在1到1000以内。红色部分是什么意思,求大神们解释一下
# include <stdio.h>double JD = 1.0E-13;
double mysqrt(double x)
{
if(x < JD) //x<=0时, 输出
return -1;
double p, q, s;
p = 0;
q = x;
s = x / 2;
while((s*s-x)>JD || (s*s-x)<-JD)
{
if(s*s-x > JD)
{
q = s;
s = p + (s-p) / 2;
}
else
{
p = s;
s = s + (q-p) / 2;
}
}
return s;
}
int main(void)
{
int a;
printf("your num: ");
scanf("%d", &a);
printf("sqrt(%d) = %lf\n", a, mysqrt(a));
return 0;
}