快速读入输出

普通快速读入

inline void Read(int &x)
{
    char c=getchar();
    x=0;
    while (c<'0'||c>'9')
    {
 
        c=getchar();
    }
    while (c>='0'&&c<='9')
    {
        x=x*10+c-'0';
        c=getchar();
    }
 
}
 
inline void Out(int a)    //输出一个整型
{
    if(a<0)
    {
          putchar('-');
          a=-a;
    }
    if(a>9)
    Out(a/10);
    putchar(a%10+'0');
}
 

 

更快的快速读入

#include<iostream>
#include<cstdio>
#include<ctime>
#include<cstring>
#include<cstdlib>
struct Scanner
{
    static const int BUF_SIZE = 65536;
    char _buf[BUF_SIZE];
    char* curPos;
    Scanner():curPos(_buf)
    {
        fread(_buf, 1, sizeof(_buf), stdin);
    }
    inline void ensureCapacity()
    {
        int size = _buf + BUF_SIZE - curPos;
        if (size < 100)
        {
            memcpy(_buf, curPos, size);
            fread(_buf + size, 1, BUF_SIZE - size, stdin);
            curPos = _buf;
        }
    }
    inline int nextInt()
    {
        ensureCapacity();
        while (*curPos <= ' ')
            ++curPos;
        register bool sign = false;
        if (*curPos == '-')
        {
            sign = true;
            ++curPos;
        }
        register int res = 0;
        while (*curPos > ' ')
            res = res * 10 + (*(curPos++) & 15);
        return sign ? -res : res;
    }
    inline char nextChar()
    {
        ensureCapacity();
        while (*curPos <= ' ')
            ++curPos;
        return *(curPos++);
    }
};


struct Outputer
{
    static const int BUF_SIZE = 65536;
    char _obuf[BUF_SIZE],*_opos;
    int pp[20];
    Outputer():_opos(_obuf){}
    template <typename T>
    inline void putInt(T x)
    {
        if (x < 0)
        {
            *_opos++ = '-';
            x = -x;
        }
        if (x)
        {
            register int now=0;
            while (x) pp[now++] = x%10,x /= 10;
            while (now) *_opos++ = pp[--now]+'0';
        }
        else
        {
            *_opos++ = '0';
        }

        if (_opos-_obuf > 64000)
        {
            fwrite(_obuf, 1, _opos-_obuf, stdout);
            _opos = _obuf;
        }
    }
    inline void putChar(char x)
    {
        *_opos++ = x;
        if (_opos-_obuf > 64000)
        {
            fwrite(_obuf, 1, _opos-_obuf, stdout);
            _opos = _obuf;
        }
    }
    ~Outputer()
    {
        if (_opos)  fwrite(_obuf, 1, _opos-_obuf, stdout);
        fflush(stdout);
    }
};

int main()
{
    Scanner sc;
    Outputer out;
    int T,a,b;
    T=sc.nextInt();
    while (T--)
    {
        a=sc.nextInt();
        b=sc.nextInt();
        out.putInt(a+b);
        out.putChar('\n');
    }
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值