import java.util.Scanner; public class AshuzuXz_b8_1 { public static void main(String[] args) { int[] array = new int[10]; System.out.println("请输入10个数:"); Scanner scanner = new Scanner(System.in); for (int i = 0; i < array.length; i++) { array[i] = scanner.nextInt();//输入十个数进行排序 } System.out.println(); for (int j = 0; j < array.length; j++) { for (int i = j; i < array.length; i++) { if (array[j] > array[i]) { int temp = array[j]; array[j] = array[i]; array[i] = temp; } } } System.out.print("排序后的为="); for (int i = 0; i < array.length; i++) { System.out.print(array[i]+" "); } } }
手动输入10个数字进行排序——选择排序
最新推荐文章于 2024-06-14 17:50:20 发布