C语言:开平方根sqrt程序02

#include <stdio.h>

int sqrt01(int x);

void main(void)
{
int x=49,y;
y=sqrt01(x);

if(y<0)
printf("Error:sqrt return %d\n",y);
else
printf("The sqrt root of %d is %d\n",x,y);
}

int sqrt01(int x)
{
int temp=x/2;

while(temp--)
{

if(temp*temp==x)
return temp;
}
return -1;
}

猜你喜欢

转载自www.cnblogs.com/caiziQuant/p/10099427.html
今日推荐