题解 | #不用加减乘除做加法#
不用加减乘除做加法
https://www.nowcoder.com/practice/59ac416b4b944300b617d4f7f111b215
class Solution { public: int Add(int num1, int num2) { int add = 0; if (num2 >= 0) { while (num2 > 0) { add++; num2--; } while (add > 0) { num1++; add--; } } else { while (num2 < 0) { add++; num2++; } while (add > 0) { num1--; add--; } } return num1; } };