取2的模,比较,不同加一,然后都右移一位
public int hammingDistance(int x, int y) {
int result=0;
while(x!=0||y!=0){
if((x%2)!=(y%2)){
result++;
}
x>>=1;
y>>=1;
}
return result;
}