顿搜
飞过闲红千叶,夕岸在哪
类目归类
Calculates the number of 1 in a binary integer
11111110100 -> 8
001011010 -> 4
int countBit(int x) {
int count = 0;
while(x != 0) {
count++;
x &= (x - 1);
}
return count;
}