方法一:使用第三方变量
int a = , b = , temp; temp = a; a = b; b = temp;
方法二:变量加减法(即121,加减减)
int a = , b = ; a = a + b; b = a - b; a = a - b;
方法三:使用按位异或
int a = , b = ; a = a ^ b; b = a ^ b; a = a ^ b;
2024-04-04 09:54:41
int a = , b = , temp; temp = a; a = b; b = temp;
方法二:变量加减法(即121,加减减)
int a = , b = ; a = a + b; b = a - b; a = a - b;
方法三:使用按位异或
int a = , b = ; a = a ^ b; b = a ^ b; a = a ^ b;
下一篇:栈溢出