leetcode 371两整数之和

 

class Solution {
public:
    int getSum(int a, int b) {
        long long carry=b;
        while(b!=0){
            carry=a&b;
            a=a^b;
            b=(carry&0xffffffff)<<1;
        }
        return a;
    }
};

 

posted @ 2019-05-30 16:31  Joel_Wang  阅读(236)  评论(0编辑  收藏  举报