题解 | #不用加减乘除做加法#
不用加减乘除做加法
https://www.nowcoder.com/practice/59ac416b4b944300b617d4f7f111b215
import java.util.*; public class Solution { public int Add(int a,int b) { while(b != 0) { int c = (a & b) << 1; // 进位 a ^= b; // 计算当前位置 b = c; // 迭代 } return a; } }