/**
* 快速排序
* @author Joban
*
*/
public class quickSort {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a[] = {2,5,3,1,4,9,2,3,1,1};
sort(a, 0, a.length-1);
for(int x :a){
System.out.print(x+" ");
}
}
public static void sort(int a[],int low,int high) {
int i = low;
int j = high;
if (low>high){
return;
}
int temp = a [low];
while(i<j){
while(i<j&&a[j]>=temp){
j--;
}
if (i<j){
a[i] = a[j];
}
while (i<j&&a[i]<=temp) {
i++;
}
if(i<j){
a[j]=a[i];
}
}
a[i] = temp;
sort(a, low, i-1);
sort(a, i+1, high);
}
}
08-19