public class Xindeooo { public static void main(String[] args) { // TODO Auto-generated method stub // 冒泡排序 int[] array = { 49, 38, 65, 97, 76, 13, 27, 19,99,32 }; for (int i = 0; i < array.length; i++) { System.out.print(array[i] + " "); } System.out.println(); for (int j = 1; j < array.length - 1; j++) { for (int i = 0; i < array.length - j; i++) { if (array[i] < array[i + 1]) { int t = array[i]; array[i] = array[i + 1]; array[i + 1] = t; } } for (int i = 0; i < array.length; i++) { System.out.print(array[i] + " "); } System.out.println(); } } }
public class Caipan { public static void main(String[] args) { int[] array = { 83, 77, 81, 97, 76, 93, 87, 89, 99, 92 }; int b = 1; for (int i = 0; i < array.length; i++) { System.out.print(array[i] + " "); } System.out.println(); for (int j = 1; j < array.length - 1; j++) { for (int i = 0; i < array.length - j; i++) { if (array[i] > array[i + 1]) { int t = array[i]; array[i] = array[i + 1]; array[i + 1] = t; } } } for (int i = 2; i < array.length - 2; i++) if (array[i] < array[i + 1]) { b = b + array[i]; } System.out.println("平均数=" + b / 6); System.out.println(); } }