模仿cin,cout的IO
#include <bits/stdc++.h>
struct IO {
IO& operator >> (char& ch) { return ch = getchar(), *this; }
template<typename T>
IO& operator >> (T& a) {
a = 0;
bool flag(0);
char ch = getchar();
while(!isdigit(ch)) flag = ch == '-', ch = getchar();
while(isdigit(ch)) a = (a << 3) + (a << 1) + (ch ^ 48), ch = getchar();
if(flag) a = -a;
return *this;
}
IO& operator << (const char& ch) { return putchar(ch), *this; }
short Stack[55];
template<typename T>
IO& operator << (T a) {
if(a < 0) a = -a, putchar('-');
int top(0);
do Stack[++top] = a % 10; while(a /= 10);
while(top) putchar(Stack[top--] | 48);
return *this;
}
} io;
int a, b;
int main() {
io >> a >> b;
io << a + b;
return 0;
}
标签:ch,char,while,IO,operator,getchar
From: https://www.cnblogs.com/cavve/p/18385607