排序算法的数组实现 -- 快速排序(四)
[cpp]static int Paration(int *a, int nstart, int nend)
{
int x = a[nend];
int temp = 0;
int i = nstart - 1;
for(int j = nstart; j < nend; j++)
{
if(a[j] < x)
{
temp = a[j];
i = i+1;
a[j] = a[i];
a[i] = temp;
}
}
temp = a[i + 1];
a[i + 1] = x;
a[nend] = temp;
return i + 1;
}
void Quick_Sort(int *a, int nstart, int nend)
{
if(nstart < nend) www.zzzyk.com
{
int nmid = Paration(a, nstart, nend);
Quick_Sort(a, nstart, nmid -1 );
Quick_Sort(a, nmid + 1, nend);
}
return;
}
作者:wchm_seu
补充:软件开发 , C++ ,