public class Remainder{
public static void main(String [] args){
/*
交换两个数值
*/
//使用临时变量
int x = 1;
int y = 2;
int temp = x;
x = y;
y = temp;
System.out.println("x= "+x+"\ty= "+y);
//使用 + -
x = 1;
y = 2;
x = x + y;
y = x - y;
x = x - y;
System.out.println("x= "+x+"\ty= "+y);
x = 1;
y = 2;
y = x + y - (x = y);
System.out.println("x= "+x+"\ty= "+y);
//使用异或
int a1 = 1;
int b1 = 2;
a1 = a1 ^ b1;
b1 = a1 ^ b1;
a1 = a1 ^ b1;
System.out.println("a1= "+a1+"\tb1= "+b1);
}
}