题目
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();sc.nextLine();Integer[] res = new Integer[n+1];//使用Integer类型for(int i=1;i<=n;i++) {res[i] = sc.nextInt();}Arrays.sort(res,1,n+1);//从下标1开始for(int i=1;i<=n;i++) {System.out.print(res[i]+" ");}System.out.println();Arrays.sort(res,1,n+1,new Comparator<Integer>() {@Overridepublic int compare(Integer o1, Integer o2) {return o2-o1;}});//从大到小排序for(int i=1;i<=n;i++) {System.out.print(res[i]+" ");} }
}