Cod sursa(job #2001958)

Utilizator felixiPuscasu Felix felixi Data 18 iulie 2017 11:17:17
Problema Tije Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.27 kb
#include<fstream>
using namespace std;
ifstream f("tije.in");
class OutParser {
private:
    FILE *fout;
    char *buff;
    int sp;
    void write_ch(char ch) {
        if (sp == 4096) {
            fwrite(buff, 1, 4096, fout);
            sp = 0;
            buff[sp++] = ch;
        } else {
            buff[sp++] = ch;
        }
    }
public:
    OutParser(const char* name) {
        fout = fopen(name, "w");
        buff = new char[5000]();
        sp = 0;
    }
    ~OutParser() {
        fwrite(buff, 1, sp, fout);
        fclose(fout);
    }
    OutParser& operator << (int vu32) {
        if (vu32 <= 9) {
            write_ch(vu32 + '0');
        } else {
            (*this) << (vu32 / 10);
            write_ch(vu32 % 10 + '0');
        }
        return *this;
    }
    OutParser& operator << (char ch) {
        write_ch(ch);
        return *this;
    }
    OutParser& operator << (const char *ch) {
        while (*ch) {
            write_ch(*ch);
            ++ch;
        }
        return *this;
    }
}g("tije.out");
int n,i,j,k;
int main()
{
    f>>n;
    for(k=n-1;k;--k)
    {
        for(i=n;i;--i)
            for(j=1;j<=k;++j) g<<i<<' '<<i+1<<'\n';
        for(i=1;i<=k;i++) g<<n+1<<' '<<1<<'\n';
    }
    return 0;
}