给出两个整数a和b, 求他们的和, 但不能使用 +
等数学运算符。
public class Solution {
/*
* @param : An integer
* @param : An integer
* @return: The sum of a and b
*/
public int aplusb(int a, int b) {
// write your code here
while (b != 0) {
int newA = a ^ b;
int newB = a & b;
a = newA;
b = newB << 1;
}
return a;
}
};