题目
Description
输入两个整数a,b,交换二者的值然后输出
Input
输入两个整数a,b
Output
输出交换值后的a,b
Sample Input
824 16
Sample Output
16 824
不适用其他的替换变量。只用ab变量做出交换的题目
代码块
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cn = new Scanner(System.in);
int a = cn.nextInt();
int b = cn.nextInt();
a = a+b;
b = a-b;
a = a-b;
System.out.println(a+" "+b);
}
}