#include <stdio.h>
int main(int argc, const char * argv[]) {
int a = 3, b = 4;
printf("a = %d, b = %d
", a, b);
/* 1.加减法
a = b - a;
b = b - a; // b - (b - a) = a
a = b + a; // a + b - a = b
printf("a = %d, b = %d
", a, b);*/
// 2.按位异或
a = a^b;
b = a^b; // a ^ b ^ b = a
a = a^b; // a ^ b ^ a = a ^ a ^ b = b
printf("a = %d, b = %d
", a, b);
return 0;
}
效果图: