标签:
int BitCount2(unsigned int n){ unsigned int c =0 ; for (c =0; n; ++c) { n &= (n -1) ; // 清除最低位的1 } return c ;}
int BitCount2(unsigned int n)
{
unsigned int c =0 ;
for (c =0; n; ++c)
n &= (n -1) ; // 清除最低位的1
}
return c ;
求二进制1的个数
原文地址:http://www.cnblogs.com/sober-reflection/p/6553450c3bf3ec2d4e9b229844809c2d.html