1 class Solution {
2 public:
3 /*
4 * @param a: The first integer
5 * @param b: The second integer
6 * @return: The sum of a and b
7 */
8 int aplusb(int a, int b) {
9 // write your code here, try to do it without arithmetic operators.
10 int result=0,num=0;
11
12 do {
13 result = a ^ b;
14 num = (a & b) << 1;
15 a = result;
16 b = num;
17 }
18 while(b != 0);
19
20 return result;
21 }
22 };