快速排序算法小结

import java.util.Scanner;


public class QuicklySort {

	/**
	 * 快速排序算法
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int[] numbers = new int[n];
			for (int i=0;i temp){
				high--;
			}
			numbers[low] = numbers[high]; //比中轴小的移动到低端
			while(low < high && numbers[low] < temp){
				low++;
			}
			numbers[high] = numbers[low]; //比中轴大的移动到高端
		}
		numbers[low] = temp; //中轴记录到尾
		return low; //返回中轴位置
	}
	public static void quickSort(int[] numbers,int low,int high){
		if (low 0){ //查看数组是否为空
			quickSort(numbers,0,numbers.length-1);
		}
	}
	public static void printArr(int[] numbers){
		for(int i=0;i

你可能感兴趣的:(Java)