package com.love.test;import java.util.Scanner;/** * @author Huowolf * Quick Sort Implementation * Fast-line is a very good sorting algorithm. * Core: Divide and conquer Law (1. Select Primitives 2. Partitions 3. Recursive child columns) */public class QuickSort {public static void QuickSort (int[] arr,int start, int end) {if (start< ; end) {int I=start, j=end, x=arr[start];//Primitive while (i<j) {//right-to-left scan less than X number while (I<j && arr[j]>=x) j--;if (i <J) arr[i++]=arr[j];//scan from left to right for numbers greater than x while (I<j && arr[i]<=x) i++;if (i<j) arr[j--]=arr[i];} arr[i]=x;//the base number quicksort (arr, start, end-1) in the last position;//recursive quicksort (arr, start+1, end);}} public static void Main (string[] args) {int[] arr = new int [10]; System.out.println ("Please enter 10 integers:"); Scanner s = new Scanner (system.in); for (int i=0;i<10;i++) {Arr[i] = S.nextint ();} System.out.println ("Order before sorting:"); for (int i=0;i<10;i++) {System.out.print (arr[i]+ "");} QuickSort (arr, 0, arr.length-1); System.out.println ("\ n sort order:"), for (int i=0;i<10;i++) {System.out.print (arr[i]+ "");}}}
refer to a Daniel's blog post, very good, blog address: http://blog.csdn.net/morewindows/article/details/6684558
Come on, yourself!!
Quick Sort (Java edition)