求一个整形中1的位数。
1
int f( int x) {
2
int n = 0 ;
3
while (x) {
4
++ n;
5
x &= x - 1 ;
6
}
7
return n;
8
}
int f( int x) {2
int n = 0 ;3
while (x) {4
++ n;5
x &= x - 1 ;6
} 7
return n;8
}

浙公网安备 33010602011771号