caizigary

c语言:开平方根sqrt程序01

#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(1)
{

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

posted on 2018-12-10 21:51  caizigary  阅读(1081)  评论(0)    收藏  举报

导航