循环对比 class Solution { public: int hammingWeight(uint32_t n) { uint32_t temp=1; int count=0; while(n>0){ if(n&temp==1)count++; n=n>>1; } return count; } };