1. public class Sort {
2. public static void sort() {
3. Scanner input = new Scanner(System.in);
4. int sort[] = new int[10];
5. int temp;
6. System.out.println("请输入10个排序的数据:");
7. for (int i = 0; i < sort.length; i++) {
8. sort[i] = input.nextInt();
9. }
10. for (int i = 0; i < sort.length - 1; i++) {
11. for (int j = 0; j < sort.length - i - 1; j++){
12. if (sort[j] < sort[j + 1]) {
13. temp = sort[j];
14. sort[j] = sort[j + 1];
15. sort[j + 1] = temp;
16. }
17. }
18. }
19. System.out.println("排列后的顺序为:");
20. for(int i=0;i<sort.length;i++){
21. System.out.print(sort[i]+" ");
22. }
23. }
24. public static void main(String[] args) {
25. sort();
26. }
27. }