c++实现写一个函数,求2个整数的和,要求在函数体内不得使用+,-* /
#include <iostream> using namespace std; int add(int x, int y) { return x+y; } int addmove(int a, int b) { if (b==0) { return a; } else { int sum = a ^b; //处理移位 11 = 0, 10 = 1,00 = 0 int jinwei = (a & b) <<1; //11 = 0; 10 = 1,00 = 0 return addmove(sum,jinwei); } } void main() { cout<<add(12,12)<<endl; cout <<addmove(12,12)<<endl; system("pause"); }