#include<stdio.h>
int main(int argc, char* argv[])
{
int a=5,b=10,c=0;
c=a;
a=b;
b=c;
printf("a=%d b=%d\n",a,b);
return 0;
}
可能会溢出:
#include<stdio.h>
int main(int argc, char* argv[])
{
int a=5,b=10;
a=a+b;
b=a-b;
a=a-b;
printf("a=%d b=%d\n",a,b);
return 0;
}
#include<stdio.h>
int main(int argc, char* argv[])
{
int a=5,b=10;
a = a ^ b;
b = a ^ b;
a = a ^ b;
printf("a=%d b=%d\n",a,b);
return 0;
}
转载于:https://blog.51cto.com/10725723/1707406