LeetCode 371. Sum of Two Integers

来源:互联网 发布:电脑技术员必备软件 编辑:程序博客网 时间:2024/06/12 01:54

不用 + , - 运算符进行加法运算。



int getSum(int a, int b) {    if(b==0) return a;    int s = a^b;    int w = (a&b)<<1;    return getSum(s,w);}


没想到还能这样,算是见识了。


0 0
原创粉丝点击