import java.util.*;
public class Demo {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int l1 = sc.nextInt();
int r1 = sc.nextInt();
int l2 = sc.nextInt();
int r2 = sc.nextInt();
Integer[] A = new Integer[100005];
for(int i = 1 ; i <= n ; i++) {
A[i] = sc.nextInt();
}
Arrays.sort(A,l1,r1 + 1); // 左闭右开所以+1
// 数组降序排序 数组必须是Integer才能用Collection.reverseOrder();
Arrays.sort(A,l2,r2 + 1,Collections.reverseOrder());
for(int i = 1 ; i <= n ; i++) {
if(i != n)
System.out.print(A[i] + " ");
else
System.out.print(A[i] );
}
}
}
蓝桥杯真题-数组部分升降序排序
于 2024-03-09 19:53:42 首次发布