C语言实现：

``````#include <stdio.h>

void swap(int *x, int *y)
{
int tmp = *x;
*x = *y;
*y = tmp;
}

int Partition(int *arr,int p,int r)
{
int x, i;
x=arr[r];
i=p-1;
for(int j=p; j<=r-1; j++)
{
if(arr[j]<=x)
{
swap(&arr[++i], &arr[j]);
}
}

swap(&arr[++i],&arr[r]);

return i;
}

void QuickSort(int *arr,int p,int r)
{
if(p<r)
{
int q=Partition(arr,p,r);
QuickSort(arr,p,q-1);
QuickSort(arr,q+1,r);
}
}

/*验证排序后的数组从小到大递增*/
int isSorted(int a[],int n)
{
for(int i = 1;i < n;i++)
{
if(a[i] < a[i-1])
return -1;
}
return 0;
}

int main()
{
int a[10] = {7,8,2,10,9,1,5,4,3,6};
QuickSort(a, 0,9);
for(int i = 0;i < 10;i++)
printf("%d ",a[i]);
if(-1 == isSorted(a, 10))
{
printf("Error for selectionSort");
}

return 0;
}``````

``````#include <stdio.h>

void swap(int *x, int *y)
{
int tmp = *x;
*x = *y;
*y = tmp;
}

void quick_sort_recursive(int arr[], int start, int end)
{
if (start >= end)
return;

int key = arr[end];
int left = start, right = end - 1;
while (left < right)
{
while (arr[left] < key && left < right)
left++;
while (arr[right] >= key && left < right)
right--;
swap(&arr[left], &arr[right]);
}
/*如果arr[left] < key，那么arr[left]将数组分为两部分，否则key将数组分为两部分*/
if (arr[left] >= key)
swap(&arr[left], &arr[end]);
else
left++;
/*上面left++是为了判断类似8 7 6 5 4这种情形,执行到此处时为4 7 6 5 8,此时left为0,无需继续递归排序左半部分*/
if (left)
quick_sort_recursive(arr, start, left - 1);

quick_sort_recursive(arr, left + 1, end);
}

void quick_sort(int arr[], int len)
{
quick_sort_recursive(arr, 0, len - 1);
}
/*验证排序后的数组从小到大递增*/
int isSorted(int a[],int n)
{
for(int i = 1;i < n;i++)
{
if(a[i] < a[i-1])
return -1;
}
return 0;
}

int main()
{
int a[10] = {7,8,2,10,9,1,5,4,3,6};
quick_sort_recursive(a, 0,9);
for(int i = 0;i < 10;i++)
printf("%d ",a[i]);
if(-1 == isSorted(a, 10))
{
printf("Error for selectionSort");
}

return 0;
}``````