371. Sum of Two Integers

371. Sum of Two Integers
【思路】:

  1. 位运算
  2. [leetcode] 371. Sum of Two Integers 解题报告
    int getSum(int a, int b) {
            int ans = a ^ b;
    int c = a & b;
    while(c != 0) {
        c <<= 1;
        int ans_prim = ans ^ c;
        c = ans & c;
        ans = ans_prim;
    }
    return ans;
    }

你可能感兴趣的:(371. Sum of Two Integers)