Pagini recente » Cod sursa (job #1530923) | Cod sursa (job #1859276) | Cod sursa (job #469589) | sim_oji111 | Cod sursa (job #1576003)
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
ifstream fin("algrost.in");
ofstream fout("algsort.out");
#define nmax 500010
#ifdef INFOARENA
#define cout fout
#endif
int n;
int v[nmax];
void quicks(int v[], int st, int dr)
{
int i = st, j = dr;
int aux;
int mij = v[(st + dr) / 2];
while (i <= j)
{
while (v[i] < mij)
i++;
while (v[j] > mij)
j--;
if (i <= j)
{
aux = v[i];
v[i] = v[j];
v[j] = aux;
i++;
j--;
}
}
if (st < j)
quicks(v, st, j);
if (i < dr)
quicks(v, i, dr);
}
int main()
{
int i;
fin>>n;
for(i=1;i<=n;++i) fin>>v[i];
//quicks(v,1,n);
sort(v+1,v+n+1);
for(i=1;i<=n;++i) cout<<v[i]<<' ';
}