萌新求助,这个快读CE了!(就当俺是个妹子帮帮忙吧……

学术版

我提供一个板子吧,也许可能比你的还快些
by MuYC @ 2018-12-22 15:43:28


```cpp int read(){ int sum=0,flag=1; char ch=getchar(); while(ch>'9'||ch<'0'){ if(ch=='-')flag=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ sum=sum*10+ch-'0'; ch=getchar(); } return sum*flag; } ```
by MuYC @ 2018-12-22 15:43:51


不建议用inline,如果长度过长,它可能比scanf还慢
by MuYC @ 2018-12-22 15:44:12


@[风骨傲天](/space/show?uid=138133) 把`x!=EOF`去掉
by RiverFun @ 2018-12-22 15:45:03


@[Mr_杨t_t](/space/show?uid=67817) 嗯,先谢谢您的板子,可是我想知道我的函数模板+快读为什么会CE,我倒不是很担心是不是很快
by Abnormal_Sir @ 2018-12-22 15:45:09


@[Steve_braveman](/space/show?uid=96570) 不行,还是有问题
by Abnormal_Sir @ 2018-12-22 15:45:41


QAQ看见快读,让我想起了一直在写快读的 @[吴蕴章](/space/show?uid=71403) 巨佬
by 自闭头铁娃 @ 2018-12-22 15:45:46


@[一只废柴墨](/space/show?uid=100967) 所以您能帮忙吗QQwQ
by Abnormal_Sir @ 2018-12-22 15:47:19


@[风骨傲天](/space/show?uid=138133) 把`char x=0;`改为`char x = getchar();`
by RiverFun @ 2018-12-22 15:48:29


```cpp #include<bits/stdc++.h> using namespace std; inline int read() { int f=1,w=0;char x=getchar(); while(x<'0'||x>'9') {if(x=='-') f=-1; x=getchar();} while(x!=EOF&&x>='0'&&x<='9') {w=(w<<3)+(w<<1)+(x^48);x=getchar();} return f*w; } int main(){ int a,b; a=read(),b=read(); cout<<a+b; return 0; } ```
by MuYC @ 2018-12-22 15:48:32


| 下一页