不能用加减法,想到用位运算解题。
本题思路可见 http://www.cnblogs.com/grandyang/p/5451942.html
关于位运算部分总结 可见 https://blog.csdn.net/fly_yr/article/details/51144272
class Solution { public: int getSum(int a, int b) { int sum=a; while(b){ sum = a^b; int carry= (a&b)<<1; a = sum; b = carry; } return sum; } };
原文:https://www.cnblogs.com/hankunyan/p/9147627.html