----------------------------------
使用位运算实现加法:
a^b 加不同部分(a&b)<<1 加相同部分递归相加
AC代码:
public class Solution { public int getSum(int a, int b) { if(b==0) return a; int t1=a^b; int t2=(a&b)<<1; return getSum(t1,t2); } }
题目来源: https://leetcode.com/problems/sum-of-two-integers/