读入优化第三行代码是
```cpp
while((c=getchar())<'0' || c>'9')
```
^^注意这里
by 「ゲームとOI」 @ 2018-10-15 12:32:29
@[「ゲームとOI」](/space/show?uid=88745) 对的
by Aleph1022 @ 2018-10-15 12:33:20
@[runtime_error](/space/show?uid=92605) isdigit了解以下= =
by 星小雨 @ 2018-10-15 12:42:33
我丢个板子怎么样$2333$
```cpp
#include <cstdio>
#include <cctype>
#include <stack>
class Fast_IO
{
static const int MAX = 1e7;
char inbuf[MAX], outbuf[MAX];
char *in, *inend, *out;
std::stack<int> stk;
void put_char(char c)
{
if(out - outbuf == MAX)
fwrite(outbuf, 1, MAX, stdout), out = outbuf;
*out ++= c;
}
char get_char()
{
return in == inend and (inend = (in = inbuf) + fread(inbuf, 1, MAX, stdin), in == inend) ? EOF : *in++;
}
public :
Fast_IO()
{
in = inend = inbuf;
out = outbuf;
while(!stk.empty())
stk.pop();
}
~Fast_IO()
{
fwrite(outbuf, 1, out - outbuf, stdout);
}
Fast_IO& operator>>(int& num)
{
num = 0;
register char c;
register int flag = 1;
while(!isdigit(c = get_char()))
if(c == '-')
flag *= -1;
while(num = (num << 3) + (num << 1) + (c ^ 48), isdigit(c = get_char()));
num *= flag;
return *this;
}
Fast_IO& operator<<(int num)
{
if(num < 0)
put_char('-'), num = -num;
do
{
stk.push(num % 10 + 48);
num /= 10;
} while(num);
while(!stk.empty())
put_char(stk.top()), stk.pop();
return *this;
}
Fast_IO& operator<<(char c)
{
put_char(c);
return *this;
}
} wib;
```
有了以上的板子, 你就可以这么用了:
```cpp
int main()
{
int a, b;
wib >> a >> b;
wib << a + b << '\n';
return 0;
}
```
当然 你也可以不用 $wib$ 这个变量名 自己取就好$2333$
(用的时候记得开文件 不能手输)
by EndSaH @ 2018-10-15 13:09:30
@[「ゲームとOI」](/space/show?uid=88745) 恍然大悟,谢谢大佬
by runtime_error @ 2018-10-16 19:30:39