快速排序

package com.datastruct.sort;

public class SelectSort {

	static void exch(int[] a, int i, int j){
		int temp = a[i];
		a[i] = a[j];
		a[j] = temp;
	}

	static void compExch(int[] a, int i, int j){
		if(a[j] < a[i])
			exch(a, i, j);
	}
	
	static void selectionSort(int[] a, int start, int end){
		for(int i = start; i < end; i++){
			int min = i;
			for(int j = i + 1; j <= end; j++){
				if(a[j] < a[min]){
					min = j;
				}
			}
			exch(a, i, min);
			for (int k = 0; k < a.length; k++) {
				System.out.print(a[k]+" ");
			}
			System.out.println("第"+i+"次结束");
		}
	}

}
 

你可能感兴趣的:(J#)