import java.util.Scanner; public class javaTasktow { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int temp;//用于交换数据的第三工具 int[] a = new int[10];//定义1存储10个数的数组 System.out.println("请输10个数,用空格隔开"); for (int i = 0; i < a.length; i++) {//循环存10个数到数组里 int arr = sc.nextInt(); a[i] = arr; for (int j = 0; j <= i - 1; j++) { if (a[j] > a[i]) { temp = a[i]; a[i] = a[j]; a[j] = temp; } } } for (int r=0;r<=9;r++) {//循环输出每一个数的值 System.out.print("从小到大排序为:"+a[r]+ "\t"); } } }
java从小到大冒号排序
最新推荐文章于 2024-08-23 15:54:50 发布