#include <cstdio>
#include <algorithm>
#include <ctime>
#include <cstdlib>
int n = 10000000, a[n];
void qsort(int l, int r)
{
if (l >= r)
return;
int t = a[rand() % n], i = l, j = r;
while (i <= j)
{
while (a[i] < t)
i++;
while (a[j] > t)
j--;
if (i <= j)
{
std::swap(a[i], a[j]);
i++;
j--;
}
}
qsort(l, j);
qsort(i, r);
}
int main ()
{
srand(time(0));
clock_t s, e;
double use;
for (int i = 0; i < n; i++)
a[i] = rand() % 1000;
s = clock();
qsort(1, n - 1);
e = clock();
use = (e - s) / CLOCKS_PER_SEC;
printf("用时:%lfs", use);
return 0;
}