public class Queen8 {
public static void sort(int a[],int start,int end)
{
if(start>=end)
return;
int j=part(a,start,end);
sop(j);
sort(a,start,j-1);
sort(a,j+1,end);
}
public static int part(int a[],int start,int end)
{
int k = a[start];
int i=start,j=end+1;
while(true)
{
while(k>a[++i]); //可以在这里加入限制,防止越界。
while(k<a[--j]);
if(i>=j)
break;
swap(a,i,j);
}
swap(a,start,j);
return j;
}
public static void swap(int []a ,int i,int j)
{
int temp=a[i];
a[i]=a[j];
a[j]=temp;
}
public static void main(String args[])
{
int a [] = {5,10,1,2,3,6,4,7,8,9,0};
sort(a,0,a.length-1);
for(int i=0;i<a.length;i++)
{
System.out.print(a[i]+",");
}
}
public static void sop(Object o)
{
System.out.println(o);
}
}