标签:
class Solution { public: int hammingWeight(uint32_t n) { uint32_t flag=1; int count=0; while(flag) { if(n&flag) count++; flag=flag<<1; } return count; } };
Number of 1 bits
原文地址:http://www.cnblogs.com/summerkiki/p/5492830.html