• 输出读入优化——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<<'
    ';
        io<<"test_string_output
    ";
        char s[111];
        io>>s;
        io<<s<<'
    ';
        io.flush();
        freopen("o.txt","w",stdout);
        for(int i=0;i<10000000;++i)io<<i<<' ';
        io.flush();
        return 0;
    }
    View Code
  • 相关阅读:
    Python openpyxl的使用
    Python字典的遍历
    Python3元组的简介和遍历
    tableau绘制饼图
    tableau创建点位地图
    tableau绘制热力地图
    select下拉框分组使用bootstrap select
    css设置div中table水平居中
    sql server的分组排序partition by函数
    document.ready
  • 原文地址:https://www.cnblogs.com/lyzuikeai/p/7396242.html
Copyright © 2020-2023  润新知