class Solution { public: int NumberOf1(int n) { int cnt = 0; for (int i = 0; i < 32; i++) { int x = (n >> i) & 1; cnt += x; } return cnt; } };