• 输入挂


    简化版:(正int输入挂)

    int read()
    {
        char ch=' ';
        int ans=0;
        while(ch<'0' || ch>'9')
            ch=getchar();
        while(ch<='9' && ch>='0')
        {
            ans=ans*10+ch-'0';
            ch=getchar();
        }
        return ans;
    }
    
    
    inline void out(int x)
    {
        if(x>9) out(x/10);
        putchar(x%10+'0');
    }

    int && long long && double 输入挂

    template <class T>
    bool scan_d(T &ret)
    {
        char c;
        int sgn;
        T bit=0.1;
        if(c=getchar(), c==EOF)
            return 0;
        while(c!='-' && c!='.' && (c<'0' || c>'9'))
            c=getchar();
        sgn=(c=='-')? -1:1;
        ret=(c=='-')? 0:(c-'0');
        while(c=getchar(), c>='0' && c<='9')
            ret=ret*10+(c-'0');
        if(c==' ' || c=='
    ')
        {
            ret*=sgn;
            return 1;
        }
        while(c=getchar(), c>='0' && c<='9')
            ret+=(c-'0')*bit, bit/=10;
        ret*=sgn;
        return 1;
    }

    完整版高速输入挂(速度快于之前两个版本)

    //-------------------输入挂
    const int MAXBUF=10000;
    char buf[MAXBUF],*ps = buf,*pe = buf+1;
    inline void rnext()
    {
        if(++ps==pe) pe=(ps=buf)+fread(buf,sizeof(char),sizeof(buf)/sizeof(char),stdin);
    }
    template<class T>
    inline bool in(T &ans)
    {
        ans=0;
        T f=1;
        if(ps==pe) return false;//EOF
        do
        {
            rnext();
            if('-' == *ps) f=-1;
        }while(!isdigit(*ps)&&ps!=pe);
        if(ps==pe) return false;//EOF
        do
        {
            ans=(ans<<1)+(ans<<3)+*ps-48;
            rnext();
        }while(isdigit(*ps)&&ps!=pe);
        ans*=f;
        return true;
    }
    
    
    
    //---------------输出挂
    
    const int  MAXOUT=10000;
    char bufout[MAXOUT],outtmp[50],*pout=bufout,*pend=bufout+MAXOUT;
    inline void write()
    {
        fwrite(bufout,sizeof(char),pout-bufout,stdout);
        pout=bufout;
    }
    inline void out_char(char c)
    {
        *(pout++)=c;
        if(pout == pend) write();
    }
    inline void out_str(char *s)
    {
        while(*s)
        {
            *(pout++)=*(s++);
            if(pout==pend) write();
        }
    }
    template <class T>
    inline void out_int(T x)
    {
        if(!x)
        {
            out_char('0');
            return;
        }
        if(x<0) x=-x,out_char('-');
        int len=0;
        while(x)
        {
            outtmp[len++]=x%10+48;
            x/=10;
        }
        outtmp[len]=0;
        for(int i=0, j=len-1;i<j;i++,j--) swap(outtmp[i],outtmp[j]);
        out_str(outtmp);
    }
    
    
    //---------------用法
    
    int main()
    {
        int t,ca=1;
        in(t);
        while(t--)
        {
            int n;
            in(n);
            out_str("Case #");
            out_int(ca++);
            out_str(": ");
            out_int(n);
            out_char('
    ');
        }
        write(); //不可少~
        return 0;
    }
  • 相关阅读:
    Serverless 解惑——函数计算如何访问 MySQL 数据库
    Kubernetes 会不会“杀死” DevOps?
    开发函数计算的正确姿势——使用交互模式安装依赖
    从零开始入门 K8s | 调度器的调度流程和算法介绍
    eclipse中如何自动生成构造函数
    微服务架构中API网关的角色
    JAVA设计模式之责任链模式
    谦先生的程序员日志之我的hadoop大数据生涯一
    谦先生的bug日志之hive启动权限问题
    CSS盒子模型之详解
  • 原文地址:https://www.cnblogs.com/mochenmochen/p/5156807.html
Copyright © 2020-2023  润新知