/** * Created by liwj on 2017/4/14. */ public class QuickSort { private static int d[]={6,1,2,5,9,3,4,7,10,8}; public static void quickSort(int left,int right){ int i,j,tp; if(left>right){ return; } tp=d[left]; i=left; j=right; while(i!=j){ while(d[j]>=tp&&i<j){ j--; } while(d[i]<=tp&&i<j){ i++; } if(i<j){ int t=d[i]; d[i]=d[j]; d[j]=t; } } d[left]=d[i]; d[i]=tp; quickSort(left,i-1); quickSort(i+1,right); } public static void main(String[] args){ quickSort(0,9); for(int i=0;i<10;i++) System.out.print(d[i]+" "); } }