class Solution {
public:
int NumberOf1(int n)
{
unsigned int temp = n;
int count = 0;
while(temp)
{
//9 % 2 = 4 余数1
//4 % 2 = 2 余数0
//2 % 2 = 1 余数0
//1 % 2 = 0 余数1
int ret = temp % 2;
if(ret == 1)
{
count++;
}
temp = temp / 2;
}
return count;
}
};