public static void main(String[] args) {
int a = 7;
int b = 1;
a = (a ^ b) ^ (b = a ^ b ^ b);
System.out.println(a);
System.out.println(b);
}
} 作者: 柏占肖 时间: 2012-9-30 15:21 本帖最后由 柏占肖 于 2012-9-30 15:30 编辑
public class Swap {
public static void main(String[] args) {
int a = 5;
int b = 4;
a ^= b ^ (b = a);
System.out.println(a + "," + b);
}
}
复制代码
作者: hello_world! 时间: 2012-9-30 17:02
public class Swap {
public static void main(String[] args) {
int a = 2;
int b = 3;
a = (b ^ a) ^ (b = a);
System.out.println(a);
System.out.println(b);
}
}