题目:Calculate the sum of two integers
a and
b, but you are
not allowed to use the operator
+ and
-.
此题一看是完全没有思路的。。。经提示要用异或^和与&和<<左移,异或用于不进位加法,与和左移用来记录进位(因为进位要进到下一位啦~)。需要考虑特殊情况,如1111+1111(异或结果为0,与结果不是,即需加上进位),1000+0100(这就是个简单的没有进位的加法~)