选择排序法-Java实现

public static void selectSort(int[] a) {
		int temp;
		int index;
		for (int i = 0; i < a.length - 1; i++) {
			for (int j = i + 1; j < a.length; j++) {
				index = i;
				if (a[j] < a[index]) 
					index = j;
				if (index != i) {
					temp = a[i];
					a[i] = a[index];
					a[index] = temp;
				}
			}
		}
	}

 

你可能感兴趣的:(Java)