Title Description
Enter an integer and output the number of 1s in the binary representation of the number. Negative numbers are represented by complements.
在这里插入代码片
public int NumberOf1(int n) {
int a=0;
while(n!=0)
{if((n&1)==1)
a++;
n=n>>>1;}
return a;
}
note: