快速排序:
1、选择一个基点(通常选取某一块中第一个元素),一趟排序下来,左边的所有数据小于基点,右边的所有数据大于基点;
2、使用递归排序;
void quick_sort(int *vector,int low,int high)
{
if (low >= high)
{
return;
}
int index = low;
int key = vector[index];
int left = low;
int right = high;
while (low < high)
{
while (vector[high] >= key && low < high)
{
high--;
}
vector[index] = vector[high];
vector[high] = key;
index = high;
while (vector[low] <= key && low < high)
{
low++;
}
vector[index] = vector[low];
vector[low] = key;
index = low;
}
quick_sort(vector,left,index - 1);
quick_sort(vector,index + 1,right);
}