class Solution { public: int NumberOf1(int n) { unsigned num = n; int count = 0; while(num){ if((num&1) == 1) count++; num >>= 1; } return count; } };