public class QuickSort{
public static void main(String[] args) {
new QuickSort();
}
public QuickSort(){
int[] a={49,38,65,97,76,13,27,49,78,34,12,64,5,4,62,99,98,54,56,17,18,23,34,15,35,25,53,51};
quick(a);
for(int i=a.length-1;i>=0;i--)
System.out.println(a[i]);
}
public int getMiddle(int a[],int row,int high){
int tmp=a[row];
while(row<high){
while(row<high&&a[high]>=tmp){
high--;
}
a[row]=a[high];
while(row<high&&a[row]<=tmp){
row++;
}
a[high]=tmp;
}
a[row]=tmp;
return row;
}
public void quickSort(int[] a,int row,int high){
if(row<high){
int midde=getMiddle(a,row,high);
quickSort(a,row,midde-1);
quickSort(a,midde+1,high);
}
}
public void quick(int[] a){
if(a!=null&&a.length>2){
quickSort(a,0,a.length-1);
}
}
}
2025 - 快车库 - 我的知识库 重庆启连科技有限公司 渝ICP备16002641号-10
企客连连 表单助手 企服开发 榜单123