【leetcode】面试题 05.06. 整数转换

 

int convertInteger(int A, int B){
    A^=B;
    int ret=0;
    for(int i=0;i<32;i++){
        if((A>>i)&1==1){
            ret++;
        }
    }
    return ret;
}

 

posted @ 2020-11-25 18:10  温暖了寂寞  阅读(82)  评论(0)    收藏  举报