理解题意: 即查找两个数的二进制位对应不相等的个数
class Solution {
public:
int hammingDistance(int x, int y) {
int count=0;
while(x!=0||y!=0)
{
if(((x&1)^(y&1))==1)//如果异或后为1,则两数不相同
count++;
x=x>>1;
y=y>>1;
}
return count;
}
};