交换两个变量的值

方法一:

int a = 8;
int b = 31;
     
int temp;
temp = a;
a = b;
b = temp;

方法二:

int a = 8;
int b = 31;
        
int sum;
sum = a + b;
b = sum - b;
a = sum - b;

方法三:

int a = 8;
int b = 31;
        
a = a ^ b;
b = a ^ b;
a = a ^ b;
原文地址:https://www.cnblogs.com/mryx/p/15594867.html