输出读入优化——QAQ

#include<bits/stdc++.h>
const int RN=1e5;
char ib[RN+5],*ip=ib+RN,ob[RN+1007],*op=ob;
inline int gc(){
    ip==ib+RN?fread(ip=ib,1,RN,stdin)[ib]=0:0;
    return*ip++;
}
struct IO{
    void flush(){
        fwrite(ob,1,op-ob,stdout),op=ob;
    }
    template<class T>//T=int,long long
    IO&operator>>(T&x0){
        T x=0;
        int f=1;
        if(ip<ib+RN-100){
            while(*ip<48)*ip++=='-'?f=-1:0;
            while(*ip>47)x=x*10+*ip++-48;
        }else{
            int c=gc();
            while(c<48)c=='-'?f=-1:0;
            while(c>47)x=x*10+c-48,c=gc();
        }
        x0=x;
        return *this;
    }
    IO&operator>>(char*s){
        int c=gc();
        while(c<33)c=gc();
        while(c>32)*s++=c,c=gc();
        *s=0;
        return *this;
    }
    template<class T>//T=int,long long,char
    IO&operator<<(T x){
        if(op>ob+RN)flush();
        int ss[25],sp=0;
        if(x<0)*op++='-',x=-x;
        do ss[++sp]=48+x%10;while(x/=10);
        while(sp)*op++=ss[sp--];
        return *this;
    }
    IO&operator<<(char x){
        if(op>ob+RN)flush();
        *op++=x;
        return *this;
    }
    IO&operator<<(const char*str){
        int n=strlen(str);
        if(op+n>ob+RN)flush();
        if(n<RN)memcpy(op,str,n),op+=n;
        else fwrite(str,1,n,stdout);
        return *this;
    }
    IO&operator<<(char*str){
        return *this<<(const char*)str;
    }
    IO&operator<<(std::string str){
        return *this<<str.data();
    }
}io;
int main(){
    freopen("in.txt","r",stdin);
    int a,b;
    io>>a>>b;
    io<<a<<'+'<<b<<'='<<a+b<<'\n';
    io<<"test_string_output\n";
    char s[111];
    io>>s;
    io<<s<<'\n';
    io.flush();
    freopen("o.txt","w",stdout);
    for(int i=0;i<10000000;++i)io<<i<<' ';
    io.flush();
    return 0;
}
View Code

 

posted @ 2017-08-19 13:08  友人Aqwq  阅读(230)  评论(0编辑  收藏  举报