题目考察的知识点:位运算

题目解答方法的文字分析:1&1=1,1&0=0,所以可以算出1的位数,然后用32减去即可

本题解析所用的编程语言:c++

class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param n int整型 
     * @return int整型
     */
    int countZeros(int n) {
        // write code here
        int count = 0;
        for (int i = 0; i < 32; ++i)
        {
            count += (n >> i) & 1;
        }
        return 32 - count;
    }
};