#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1000010;
int n;
int q[N];
void quick_sort(int l, int r) // 快速排序
{
if (l >= r) return;
int i = l - 1, j = r + 1, x = q[(l + r) / 2];
while (i < j)
{
do i ++ ; while (q[i] < x);
do j -- ; while (q[j] > x);
if (i < j) swap(q[i], q[j]);
}
quick_sort(l, j);
quick_sort(j + 1, r);
}
int main()
{
for(int i = 0;i < 10 ;i ++) scanf("%d ",&q[i]);
quick_sort(0,9);
for(int i = 0;i < 10 ;i ++) printf("%d ",q[i]);
return 0;
}
标签:sort,include,八大,int,while,++,算法,quick,排序
From: https://blog.51cto.com/u_15623277/6600069