package com.paixu;
public class QuickSort {
public int quicksort(int[] src,int low ,int high){
int l = src[low];
int pivotkey = src[low];
while(low<high){
while((low<high)&&(src[high]>=pivotkey)){
high--;
}
src[low] = src[high];
while((low<high)&&(src[low]<=pivotkey)){
low++;
}
src[high] = src[low];
}
src[low] = l;
for(int i=0;i<src.length;i++){
System.out.print(src[i]+" ");
}
System.out.println();
return low;
}
public void qsort(int[] src ,int low ,int high){
QuickSort qs = new QuickSort();
if(low<high){
int pivotloc = qs.quicksort(src, low, high);
qsort(src, low, pivotloc-1);
qsort(src, pivotloc+1,high);
}
}
public static void main(String[] args) {
int[] src = {49,38,65,97,76,13,27,49};
new QuickSort().qsort(src, 0, src.length-1);
}
}
public class QuickSort {
public int quicksort(int[] src,int low ,int high){
int l = src[low];
int pivotkey = src[low];
while(low<high){
while((low<high)&&(src[high]>=pivotkey)){
high--;
}
src[low] = src[high];
while((low<high)&&(src[low]<=pivotkey)){
low++;
}
src[high] = src[low];
}
src[low] = l;
for(int i=0;i<src.length;i++){
System.out.print(src[i]+" ");
}
System.out.println();
return low;
}
public void qsort(int[] src ,int low ,int high){
QuickSort qs = new QuickSort();
if(low<high){
int pivotloc = qs.quicksort(src, low, high);
qsort(src, low, pivotloc-1);
qsort(src, pivotloc+1,high);
}
}
public static void main(String[] args) {
int[] src = {49,38,65,97,76,13,27,49};
new QuickSort().qsort(src, 0, src.length-1);
}
}