剑指 offer 计算整数里面 1 的个数

class Solution {
public:
     int  NumberOf1(int n) {
         int count = 0;
         while(n){
                 count ++;
                 n = (n-1) &n;
             }
         return count;
     }
};
发布了95 篇原创文章 · 获赞 8 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/ttomchy/article/details/104596789
今日推荐