1.使用临时变量temp作为一个中转站交换
int a=4,b=9,temp; temp=a; a=b; b=temp;
缺点:占用内存,效率最低。 2.利用加减法实现两个变量之间的交换
int a=1,b=2