class Solution {
public:
int add(int num1, int num2){
//用^来表示无进位加法,用&表示进位
while(num2){
int sum = num1 ^ num2;
int carry = (num1 & num2) << 1; //注意运算符优先级,不加括号会错
num1 = sum;
num2 = carry;
}
return num1;
}
};