Cod sursa(job #2243481)

Utilizator andrei42Oandrei42O andrei42O Data 20 septembrie 2018 17:52:22
Problema Sortare prin comparare Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.89 kb
#include <bits/stdc++.h>

using namespace std;
const int b = 32000;
struct parser
{
    char *B,*E,*p;
    parser()
    {
        B = new char [ b + 10 ];
        E = B + b;
        LoadBuffer();

    }
    parser &operator>>(int &x)
    {
        while( *p < '0' || '9' < *p)if(++p==E)LoadBuffer();
        x=0;
        while( '0' <= *p && *p <= '9')
        {
            x = 10*x + *p - '0';
            if(++p==E)LoadBuffer();
        }
        return *this;
    }
    void LoadBuffer()
    {
        p=B;
        memset(B,0,b);
        fread(B,1,b,stdin);
    }
};
vector<int> v;
int n,x;
int main()
{
    freopen("algsort.in","r",stdin);
    freopen("algsort.out","w",stdout);
    parser f;
    f>>n;
    for(;n;n--)
    {
        f>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(auto it:v)
        printf("%d ",it);
    return 0;
}