赞
踩
-
- import java.util.Scanner;
-
- public class Sort {
- public static void main(String args[]) {
- System.out.println("请输入10个想要排序的数:");
- Scanner numbers = new Scanner(System.in);//从键盘接收数据
- int b[] = new int[10];
- for (int i = 0; i < 10; i++) {
- b[i] = numbers.nextInt();
- }
-
- int num;//中间变量
- for (int i = 0; i < 9; i++) {
- for (int j = i + 1; j < 10; j++) {
- if (b[i] < b[j]) {//从大到小排序
- num = b[i];
- b[i] = b[j];
- b[j] = num;
- }
- }
- }
- for (int i = 0; i < 10; i++) {
- System.out.print(b[i] + " ");//输出排序结果
- }
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。