给出两个整数a和b, 求他们的和, 但不能使用 + 等数学运算符。
public int aplusb(int a, int b) {
// write your code here
if((a&b)==0){
return a^b;
}else{
return aplusb(a^b,(a&b)<<1);
}
}
给出两个整数a和b, 求他们的和, 但不能使用 + 等数学运算符。
public int aplusb(int a, int b) {
// write your code here
if((a&b)==0){
return a^b;
}else{
return aplusb(a^b,(a&b)<<1);
}
}