快读与快写

最近为了做题卡常数,从网上找了一些快读的板子,

经过多次试验,下面这个板子是比较优秀的。。

const int ch_top=4e7+3;
char ch[ch_top],*now_r=ch-1,*now_w=ch-1;

inline int read(){
    while(*++now_r<'0');
    register int x=*now_r-'0';
    while(*++now_r>='0')x=x*10+*now_r-'0';
    return x;
}

inline void write(int x){
    static char st[20];static int top;
    while(st[++top]='0'+x%10,x/=10);
    while(*++now_w=st[top],--top);
    *++now_w='\n';
}


int main()
{
    fread(ch,1,ch_top,stdin);
    x=read();
    write(x);
    fwrite(ch,1,now_w-ch,stdout);
}

不知为啥本地编译器上不能用键盘输入。。

但可以用洛谷在线IDE

然而能否把它背过还是个问题

猜你喜欢

转载自www.cnblogs.com/yjkhhh/p/9404028.html