int NumberOf1(int n ) { // write code here int i = 0; int mask; int count = 0; while (i <= 31) { mask = 1 << i; if (n & mask) count++; i++; } return count; }
int NumberOf1(int n ) { // write code here int i = 0; int mask; int count = 0; while (i <= 31) { mask = 1 << i; if (n & mask) count++; i++; } return count; }