Cod sursa(job #692786)

Utilizator laurionLaurentiu Ion laurion Data 26 februarie 2012 19:28:49
Problema Sortare prin comparare Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.79 kb
// problema sortare, arhiva educationala, varianta C
# include <algorithm>
# include <cstdio>
using namespace std;

# define verf ++poz == hg ? fread ( ch, 1, hg, stdin ), poz = 0 : 0

const char *FIN = "algsort.in", *FOU = "algsort.out";
const int MAX = 500001, hg = 1 << 13;

int N, poz, A[MAX];
char ch[hg];

inline void cit ( int &x ) {
    if ( ch[0] == '\0' ) fread ( ch, 1, hg, stdin ) ;
    else for ( ; ch[poz] < '0' || ch[poz] > '9' ; verf ) ;
    for ( x = 0 ; ch[poz] >= '0' && ch[poz] <= '9' ; x = x * 10 + ch[poz] - '0', verf ) ;
}

int main (void) {
    freopen (FIN, "r", stdin);
    freopen (FOU, "w", stdout);

    cit (N);
    for (int i = 0; i < N; ++i)
        cit (A[i]);
    sort (A, A + N);
    for (int i = 0; i < N; ++i)
        printf ("%d ", A[i]);
}