Cod sursa(job #2257471)

Utilizator Tataru_AdelinTataru Adelin Tataru_Adelin Data 10 octombrie 2018 09:25:31
Problema Sortare prin comparare Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.87 kb
#include <bits/stdc++.h>

using namespace std;
const int lg=32000;
struct reader
{
    char b[lg+5];
    int i;
    reader()
    {
        freopen("algsort.in","r",stdin);
        freopen("algsort.out","r",stdin);
        i=lg-1;
        inc();
    }
    void operator>>(int &x)
    {
        while(b[i]<'0'||b[i]>'9')inc();
        x=0;
        while(b[i]>='0'&&b[i]<='9')
        {
            x=10*x+b[i]-'0';
            inc();
        }
    }
    void operator>>(vector<int> &v)
    {
        v.resize(0);
        int n,x;
        *this>>n;
        for(;n;n--){*this>>x;v.push_back(x);}
        sort(v.begin(),v.end());
        for(auto it:v)
        printf("%d ",it);

    }
    void inc()
    {
        i++;
        if(i==lg)
        {
            i=0;
            fread(b,1,lg,stdin);
        }
    }
};
int n;
vector<int> v;
int main()
{
    reader f;
    f>>v;
    return 0;
}