/*经典划分函数*/
int Partition(int data[],int start,int end)
{
if(data == NULL || start > end)
cerr <<"Invalid Paramenters"<< endl;
int index = Random(start,end); //start~end之间的随机数
cout <<"index = "<< index << endl;
Swap(data[index],data[end]);
int small = start - 1;
for(int index = start; index < end; ++index)
{
if(data[index] < data[end])
{
++small;
if(small != index)
{
Swap(data[index],data[small]);
}
}
}
++small;
Swap(data[small],data[end]);
return small;
}