题目:
解答:
1 class Solution {
2 public:
3 int hammingWeight(uint32_t n)
4 {
5 int res = 0;
6 while(n != 0)
7 {
8 res += n & 1;
9 n >>= 1;
10 }
11 return res;
12 }
13 };
标签:11,hammingWeight,面试题,12,15,二进制,res,int
来源: https://www.cnblogs.com/ocpc/p/12857022.html