冒泡排序 实现代码 实现代码 public static void main(String[] args) { //按用户意愿生成一维随机数组 Scanner scanner = new Scanner(System.in); System.out.println("input how many random numbers you want:"); int len = scanner.nextInt(); int[] array = new int[len]; for (int i = 0; i < array.length ;i++){ array[i] = (int)(Math.random() * (100 - 10 ) + 10); } System.out.println(Arrays.toString(array)); //按用户意愿生成一维随机数组 for(int i = 0; i < array.length ; i++){ for (int j=0 ; j < array.length - 1 - i; j++){ if(array[j] > array[j + 1]){ int temp= array[j]; array[j] =array[j + 1]; array[j + 1] = temp; } } } System.out.println("Sorted array:" + "\n" + Arrays.toString(array)); }