A + B Problem

Write a function that add two numbers A and B. You should not use + or any arithmetic operators.

分析:

典型的Bit Operation.

 class Solution {
/*
* param a: The first integer
* param b: The second integer
* return: The sum of a and b
*/
public int aplusb(int a, int b) {
if (a == ) return b;
int sum = a ^ b;
int carry = (a & b) << ;
return aplusb(carry, sum);
}
};
上一篇:清除SQL Server 2008中登陆时的历史记录


下一篇:js控制进度条到达100%跳转界面一