#include
using namespace std;
//快速排序,在子函数中,数组已被改变
void quick_sort(int *a, int left, int right) //left和right为索引值
{
int temp; //存储每次选定的基准数(从最左侧选基准数)
int t;
int initial=left;
int end=right;
temp=a[left];
//***必须有这一部分***//
if (left>right) //因为在递归过程中有减1加1的情况,当其越界时,直接return,不返回任何值,即结束当前程序块
return;
while(left!=right) //此时左右index在移动中,若left==right,则跳出循环,将基数归位
{
while(a[right]>=temp && left
关注
打赏