【leetcode】 汉明距离

int hammingDistance(int x, int y){
    x = x^y;
    int num=0;
    while(x){
        num += x & 1;
        x >>=1; 
    }
    return num;
}
原文地址:https://www.cnblogs.com/ganxiang/p/13737782.html