标签:
1 class Solution { 2 public: 3 int hammingWeight(uint32_t n) { 4 int result = 0; 5 while (n > 0) { 6 if (n & 1) { 7 result++; 8 } 9 n >>= 1; 10 } 11 return result; 12 } 13 };
LeetCode – Refresh – Number of 1 Bits
标签:
原文地址:http://www.cnblogs.com/shuashuashua/p/4355192.html