快速排序

来源:互联网 发布:淘宝猪哼少 编辑:程序博客网 时间:2024/06/05 15:01
void qs(int a[], int begin, int end){int compare = a[begin], left = begin, right = end;if (left > right)return;while (left < right){while ((left < right) && a[right] >= compare)right--;a[left]=a[right];while ((left < right) && (a[left] < compare))left++;a[right]=a[left];}a[left]=compare;qs(a, begin, left - 1);qs(a, left + 1, end);}