第一种:使用中间变量
int a = 1, b = 2, c;
c = a;
a = b;
b = c;
printf(“%d,%d”, a, b);
第二种:
int a = 1, b = 2;
a = a + b;
b = a - b;
a = a - b;
printf(“%d%d”, a, b);
或者:
a = a * b;
b = a / b;
a = a / b;
第三种:
int a = 1, b = 2;
a ^= b;
b ^= a;
a ^= b;
printf(“%d,%d”, a, b);
int a = 1, b = 2;
b = (_int64)((_int64) a << 32 | (a = b)) >> 32;
printf(“%d,%d”, a, b);
时间: 2024-10-28 23:39:08