代码如下:
#include <stdio.h> typedef unsigned int u32; u32 plus (u32 A, u32 B) { u32 C, D; C = A^B; D = A&B; while(D != 0) { D = D<< 1; A = C; B = D; C = A^B; D = A&B; } return C; } main() { printf("%d\n", plus(3, 40) == 43); printf("%d\n", plus(30, 40) == 70); printf("%d\n", plus(3, 400) == 403); printf("%d\n", plus(3000, 400) == 3400); }
参考: http://zhidao.baidu.com/question/535671893?quesup2&oldq=1