public int setBitCount(int n)
{
//Count the number of bits which are 1
int count=0;
while(n!=0)
{
if((n&1)>0)
{
count++;
}
n=n>>>1;
}
return count;
}
{
//Count the number of bits which are 1
int count=0;
while(n!=0)
{
if((n&1)>0)
{
count++;
}
n=n>>>1;
}
return count;
}
No comments:
Post a Comment