代码
public
void
QuickSort(List
<
int
>
sqlist,
int
low,
int
hight)
{
int i;
if (low > hight) return ;
i = Partition(sqlist, low, hight);
QuickSort(sqlist, low, i - 1 );
QuickSort(sqlist, i + 1 , hight);
}
private int Partition(List < int > sqllist, int p, int q)
{
int i, j;
i = p;
j = q;
int temp = sqllist[i];
while (i < j)
{
while (sqllist[j] > temp && i < j) j -- ;
if (i < j)
{ sqllist[i] = sqllist[j]; i ++ ; }
while (sqllist[i] < temp && i < j) i ++ ;
if (i < j)
{
sqllist[j] = sqllist[i];
j -- ;
}
}
sqllist[i] = temp;
return i;
}
{
int i;
if (low > hight) return ;
i = Partition(sqlist, low, hight);
QuickSort(sqlist, low, i - 1 );
QuickSort(sqlist, i + 1 , hight);
}
private int Partition(List < int > sqllist, int p, int q)
{
int i, j;
i = p;
j = q;
int temp = sqllist[i];
while (i < j)
{
while (sqllist[j] > temp && i < j) j -- ;
if (i < j)
{ sqllist[i] = sqllist[j]; i ++ ; }
while (sqllist[i] < temp && i < j) i ++ ;
if (i < j)
{
sqllist[j] = sqllist[i];
j -- ;
}
}
sqllist[i] = temp;
return i;
}