package Sort; public class QuickSort { public static void main(String[] args){ int[] list={0,5,9,2,6,8,1,4}; quickSort(list); for(int i=0;i<list.length;i++){ System.out.print(list[i]+"¡¡"); } } public static void quickSort(int[] list){ quickSort(list,0,list.length-1); } private static void quickSort(int[] list,int first,int last){ if(last>first){ int index=partition(list,first,last); quickSort(list,first,index-1); quickSort(list,index+1,last); } } private static int partition(int[] list,int first,int last){ int pivot=list[first]; int low=first+1; int high=last; while(high>low){ while(list[low]<=pivot&&low<=high&&low<list.length-1){ low++; } while(list[high]>pivot&&low<=high&&high>0){ high--; } if(high>low){ int temp=list[low]; list[low]=list[high]; list[high]=temp; } } while(high>first&&list[high]>=pivot){ high--; } if(pivot>list[high]){ list[first]=list[high]; list[high]=pivot; return high; } else return first; } }

akirasu LV1
2021年5月14日
15286210829 LV8
2020年7月20日
zfeng9939 LV4
2020年6月29日
FFF112233 LV8
2019年11月6日
数据库1 LV12
2019年10月29日
seanc326 LV2
2019年8月19日
低调人 LV38
2019年7月11日
hjc19951212 LV2
2019年4月25日
摘星星的老鼠 LV8
2019年2月24日
DawnWalker LV19
2018年9月11日