剑指 Offer 65. 不用加减乘除做加法

class Solution {
    public int add(int a, int b) {
        while(b!=0) {
            int c = (a & b)<<1;
            int n = a ^ b;
            a = n;
            b = c;
        }
        return a;
    }
}

你可能感兴趣的