1、定义中间变量
int a = 1,b = 2,t ;
t = a;
a = b;
b = t;
2、求和,可不用定义中间变量
int a = 1,b = 2;
a = a + b;
b = a - b;
a = a - b;
3、异或
int temp = p ^ q;
p = temp ^ p;
q = temp ^ q;
时间: 2024-11-05 18:11:09
1、定义中间变量
int a = 1,b = 2,t ;
t = a;
a = b;
b = t;
2、求和,可不用定义中间变量
int a = 1,b = 2;
a = a + b;
b = a - b;
a = a - b;
3、异或
int temp = p ^ q;
p = temp ^ p;
q = temp ^ q;