方法二 不建立临时变量
#include<stdio.h>
int main(){
int a = 10;
int b = 20;
a = a + b;
b = a - b;
a = a - b;
printf("%d %d\n", a, b);
system("pause");
return 0;
}
方法三
按位异或
#include<stdio.h>
int main(){
int a = 10;
int b = 20;
a = a^b;
b = a^b;
a = a^b;
printf("%d %d", a, b);
system(“pause”);
return 0;
}