Jun 8, 2009

Describe an alogrithm to find out if an integer is a square

bool checkSquare(int num, int max, int min)
{
if(max int temp=(max+min)/2;
if(temp*temp==num)
return true;
else if(temp*temp>num);
return checkSquare(num,temp-1,min);
else
return checkSquare(num,max,temp+1);
}

No comments:

Post a Comment