package chapter1; public class Selectionsort { /** * 选择排序 * @param args */ public static void selectionSort(int[] list) { int j , k, min; for (j = 0; j < 8 - 1; j++) { min = j; for (k = j; k < 8; k++) { if (list[j] > list[k]) { int temp = list[j]; list[j] = list[k]; list[k] = temp; } } } } public static void main(String[] args) { int list[] = new int[8]; for (int i = 0 ; i < 8; i++) { list[i] = 100 - i; } selectionSort(list); for (int o : list) { System.out.println(o + " "); } } }