Cod sursa(job #821689)

Utilizator daniel.pDaniel daniel.p Data 22 noiembrie 2012 16:34:24
Problema Sortare prin comparare Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.46 kb
#include<fstream>
#include<algorithm>
#define NMAX 500000
using namespace std;
ifstream in("algsort.in");
ofstream out("algsort.out");

int v[NMAX],n;

int cmp( const void *x, const void *y )
{
    return *(int*)x - *(int*)y;
}



int main (void)
{
    in>>n;
    for(int i=0;i<n;++i)
        in>>v[i];
    in.close();

    qsort( v, n, sizeof(int), cmp );

    for(int i=0;i<n;++i)
        out<<v[i]<<" ";
    out.close();
    return 0;
}