方法1:
a = a + b;
b = a - b;
a = a - b;
方法2:
a ^= b;
b ^= a;
a ^= b;
方法3:
a = a * b;
b = a / b;
a = a / b;
不适用临时空间,交换变量a和b
时间: 2024-10-25 17:06:02
方法1:
a = a + b;
b = a - b;
a = a - b;
方法2:
a ^= b;
b ^= a;
a ^= b;
方法3:
a = a * b;
b = a / b;
a = a / b;
不适用临时空间,交换变量a和b