若为降序排列,就倒着输出
import java.util.Scanner;
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int num = input.nextInt();
int array[] = new int[num];
for(int i=0;i<num;i++){
array[i] = input.nextInt();
}
Arrays.sort(array);
for(int n:array)
System.out.print(n+" ");
input.close();
}
}
参考:
Java—Sort排序:
https://blog.csdn.net/whp1473/article/details/79678974
Java 对数组和集合的排序:
https://www.cnblogs.com/minshia/p/6283858.html