原理是替换掉了默认的cin 和 cout,可以自行改为更为高效的实现
1
2
3
4
5
6
7struct myinput{ operator bool() const { return !feof(stdin); } }cin;
struct myoutput{}cout;
struct myendl{}endl;
myoutput &operator<<(myoutput &myoutput, int s) { printf("%d", s); return myoutput; }
myoutput &operator<<(myoutput &myoutput, myendl en){ printf("\n"); return myoutput; }
myoutput &operator<<(myoutput &myoutput, const char *s) { printf("%s", s); return myoutput; }
myinput &operator>>(myinput &myinput, int &s){ if(myinput) scanf("%d", &s); return myinput; }