1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int add(int a, int b) 5 { 6 int sum, jinwei; 7 do 8 { 9 //没进位的加法结果 10 sum = a^b; 11 //求出总的进位 12 jinwei = (a&b) << 1; 13 a = sum; 14 b = jinwei; 15 } while (jinwei != 0); 16 17 return sum; 18 } 19 20 void main() 21 { 22 printf("%d ", add(1, 3)); 23 24 system("pause"); 25 }