问题描述:
写一个函数,求两个整数之和,要求在函数体内不得使用+、-、*、/四则运算符号。
源码:
class Solution {
public:
int Add(int num1, int num2)
{
int sum, carry;
do{
sum = num1 ^ num2;
carry = (num1 & num2)<<1;
num1 = sum;
num2 = carry;
}while(carry!=0);
return sum;
}
};
来源:CSDN
作者:凡凡.cs
链接:https://blog.csdn.net/fanyuwgy/article/details/104130554