#include <bits/stdc++.h>
using namespace std;
#define MAXSIZE 200000
typedef int KeyType;
typedef struct {
KeyType key;
}RedType;
typedef struct {
RedType r[MAXSIZE + 1];
int length;
}SqList;
int Random(int start, int end){
int dis = end - start;
return rand() % dis + start;
}
int Partition(SqList &L, int low, int high) {
int pivotkey;
L.r[0] = L.r[low];
pivotkey = L.r[low].key;
while(low < high) {
while(low < high && L.r[high].key >= pivotkey) --high;
L.r[low] = L.r[high];
while(low < high && L.r[low].key <= pivotkey) ++low;
L.r[high] = L.r[low];
}
L.r[low] = L.r[0];
return low;
}
void QSort(SqList &L, int low, int high) {
int pivotloc;
if(low < high) {
pivotloc = Partition(L, low, high);
QSort(L, low, pivotloc - 1);
QSort(L, pivotloc + 1, high);
}
}
void QuickSort(SqList &L) {
double start_time, finish_time, cord_time;
start_time = clock();
QSort(L, 1, L.length);
finish_time = clock();
cord_time = (double)(finish_time - start_time) ;
printf("QuickSort time=%f ms\n", cord_time);
}
void InPut(SqList &L) {
int i;
srand((unsigned)time(NULL));
cin >> L.length;
for (i = 1; i <= L.length; ++i) {
// cin >> L.r[i].key;
L.r[i].key = Random(1, 1000000);
}
}
void OutPut(SqList &L) {
int i;
for (i = 1; i <= L.length; ++i) {
cout << L.r[i].key << " ";
}
}
int main() {
SqList L;
// L.r = new RedType[MAXSIZE +1];
InPut(L);
QuickSort(L);
OutPut(L);
return 0;
}