题目链接:https://leetcode.cn/problems/hamming-distance/
题目如下:
class Solution {
public:
int hammingDistance(int x, int y) {
int res=0;
unsigned int t1=x,t2=y;
while(t1&&t2){
if((t1&1)==(t2&1)) ;
else res++;
t1>>=1;
t2>>=1;
}
while(t1){
if(t1&1) res++;
t1>>=1;
}
while(t2){
if(t2&1) res++;
t2>>=1;
}
return res;
}
};