#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"); }
时间: 2024-10-09 04:41:17