33,311
社区成员
发帖
与我相关
我的任务
分享
int count(unsigned int x) {
int i = 0;
for(i = 0; x >= 0; x /= 2)
{
i = x%2;
}
return i;
}
}
int count(unsigned int x) {
x = x - ((x >> 1) & 0x55555555);
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = (x + (x >> 4)) & 0x0F0F0F0F;
x = x + (x >> 8);
x = x + (x >> 16);
return x & 0x0000003F;
}