不使用加号,计算A+B的结果
public class Solution {
/**
* @param a: An integer
* @param b: An integer
* @return: The sum of a and b
*/
public int aplusb(int a, int b) {
// write your code here
return plus(a,b);
}
public int plus(int a,int b){
if(b==0){
return a;
}
int m = a^b;
//进位
int n = (a&b)<<1;
return plus(m,n);
}
}