力扣[LeetCode].371.两整数之和

在这里插入图片描述

class Solution {
    
    
public:
    int getSum(int a, int b) {
    
    
        if(!a) return b;
        int sum=a^b,carry=(unsigned)(a&b)<<1;
        return getSum(carry,sum);
    }
};

猜你喜欢

转载自blog.csdn.net/weixin_45488131/article/details/108902111