//url:https://leetcode.com/problems/hamming-distance/description/
class Solution {
public:
int hammingDistance(int x, int y) {
int distance=0;
int result=x^y; //XOR操作,位相同时为0,不同时为1
while(result>0){
result&=(result-1); //将result最后一位为1的位置为0
distance++;
}
return distance;
}
};