码迷,mamicode.com
首页 > 其他好文 > 详细

LeetCode 371. 两整数之和 Sum of Two Integers

时间:2020-05-30 01:24:53      阅读:70      评论:0      收藏:0      [点我收藏+]

标签:sum   integer   int   style   gets   div   src   sign   png   

技术图片

 

 不断更新值和进位。

class Solution {
public:
    int getSum(int a, int b) {
        return b == 0 ? a : getSum(a ^ b, ((unsigned int)a & b) << 1);
    }
};

 

LeetCode 371. 两整数之和 Sum of Two Integers

标签:sum   integer   int   style   gets   div   src   sign   png   

原文地址:https://www.cnblogs.com/ZSY-blog/p/12990209.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!