- #include<stdio.h>
- void sum(int a,int b);
- int main(){
- int a,b;
- scanf("%d %d",&a,&b);
- sum(a,b);
- return 0;
- }
- void sum(int a,int b){
- int sum,flag;
- do{
- sum=a^b;
- flag=(a&b)<<1;
- a=sum;
- b=flag;
- }while(b!=0);
- printf("%d\\n",sum);
- }
- //该片段来自于http://www.codesnippet.cn/detail/2610201513895.html
来源: http://www.codesnippet.cn/detail/2610201513895.html