给你一个模板,你自己看看就会了。
import java.util.Scanner;
public class $ {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int size = 3;
int[] arr = new int[size];
for (int i = 0; i < size; i++) {
System.out.print("输入第" + (i + 1) + "个数:");
arr[i] = in.nextInt();
}
import java.util.Scanner;
public class Test_1 {
public static void main(String[] args){
Scanner reader = new Scanner(System.in);
int a = reader.nextInt();
int b = reader.nextInt();
if(a>b)
{
System.out.println(a);
System.out.println(b);
}
else
{
System.out.println(b);
System.out.println(a);
}
}
}
或者
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner reader = new Scanner(System.in);
int a = reader.nextInt();
int b = reader.nextInt();
System.out.println(a>b?a:b);
System.out.println(a>b?b:a);
}
}