题目链接:https://leetcode-cn.com/problems/er-jin-zhi-zhong-1de-ge-shu-lcof/
题目如下:
class Solution {
public:
int hammingWeight(uint32_t n) {
unsigned int _n=n;
int result=0;
while(_n){
if(_n&1) result++;//求最后一位
_n>>=1;//移除最后一位
}
return result;
}
};