import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
a=a^b;
b=a^b;
a=a^b;
System.out.println(a+" "+b);
}
}
二、通过加减运算
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
a = (a+b) - (b=a);
System.out.println(a+" "+b);
}
}
三、通过第三个变量
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
int c=0;
c=a;
a=b;
b=c;
System.out.println(a+" "+b);
}
}