class Solution {
public:
int getSum(int a, int b) {
while(b != 0){
int c = (unsigned)(a&b) << 1; //存储a+b的进位信息,其中i是第几次进行循环体
a = a^b; //结果相加
b = c;
}
return a;
}
};
leetcode371+Sum of Two Integers+与及异或模拟加法
最新推荐文章于 2024-08-23 11:46:54 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)