题解 | #不用额外变量交换两个整数的值#
不用额外变量交换两个整数的值
http://www.nowcoder.com/practice/1827258942284b2abfe65809785ac91a
import java.util.Scanner; import java.io.*; public class Main { public static void main(String[] args){ Scanner in=new Scanner(System.in); int a=in.nextInt(); int b=in.nextInt(); // a=a^b; // b=a^b; // a=a^b; a=a+b; b=a-b; a=a-b; System.out.println(a+" "+b); } }