这次没有题目水字数了,记录一个很棒的快速排序模板!!
void Qsort(int beg, int end) {
int mid = str[(beg + end) / 2];
int i = beg, j = end;
do {
while (str[i] < mid)i++;
while (str[j] > mid)j--;
if (i <= j) {
swap(str[i], str[j]);
i++;
j--;
}
} while (i <= j);
if(beg<j)Qsort(beg,j);
if(i<end)Qsort(i, end);
}
标签:end,int,mid,beg,P1177,str,排序,模板
From: https://www.cnblogs.com/zhywyt/p/17084252.html