public class QuickSort {
public static void main(String[] args) {
Random random=new Random();
int[] pData=new int[10];
for(int i=0;i
Integer a =random.nextInt(100);
pData[i]= a;
System.out.print(pData[i]+" ");
}
System.out.println();
int left=0;
int right=pData.length-1;
Sort(pData,left,right);
for(int i=0;i
System.out.print(pData[i]+" ");
}
System.out.println();
}
public static int[] Sort(int[] pData, int left, int right){
int middle,strTemp;
int i = left;
int j = right;
middle = pData[(left+right)/2];
do{
while((pData[i]
i++;
while((pData[j]>middle) && (j>left))
j--;
if(i<=j){
strTemp = pData[i];
pData[i] = pData[j];
pData[j] = strTemp;
i++;
j--;
}
for(int k=0;k
System.out.print(pData[k]+" ");
}
System.out.println();
}while(i
if(left
Sort(pData,left,j); //递归调用
if(right>i)
Sort(pData,i,right); //递归调用
return pData;
}
}