LintCode(1)-A+B问题

一、直接return a+b;

二、位运算

int aplusb(int a, int b) {

        // write your code here

        if(a == 0)

        return b;

        if(b == 0)

        return a;

        int x = a^b;

        int y = (a&b) <<1;

        return aplusb(x, y);

    }

猜你喜欢

转载自blog.csdn.net/Qmingwt/article/details/125820755
今日推荐