谁有快读快输的模板?

在线等

急急急
#悬赏#
全部评论
struct ios { inline char nc() { static const int maxx=1<<18|1; static char buf1[maxx],*s,*t; return (s==t)&&(t=(s=buf1)+fread(buf1,1,maxx,stdin)),s==t?-1:*s++; } char buf2[1<<21]; int top,maxxx; inline void flush() { fwrite(buf2,1,top+1,stdout),top=-1; } inline void putc(char x) { if(top==maxxx)flush(); buf2[++top]=x; }          template <typename _Tp> inline ios & operator >> (_Tp&x) { static char ch1,ch2; for(ch1=nc(),ch2=0; !isdigit(ch1); ch1=nc()) { if(ch1==-1)return *this; ch2|=ch1=='-'; } for(x=0; isdigit(ch1); ch1=nc())x=x*10+(ch1^'0'); if(ch1=='.') { ch1=nc(); double tmp; int len=0; for(tmp=0; isdigit(ch1); ch1=nc())tmp=tmp*10+(ch1^'0'),len++; while(len--) tmp/=10; x+=tmp; } ch2&&(x=-x); return *this; } template <typename _Tp> inline ios & operator << (_Tp x) { static char buf3[15]; static int len = -1; if(x>=0) do buf3[++len]=x%10+48,x/=10; while(x); else { putc('-'); do buf3[++len]=-(x%10)+48,x/=10; while(x); } while(len>=0) { putc(buf3[len]); --len; } }    ios() { top=-1; maxxx=(1<<21)-1; } } io; 读入: io>>x; 输出: io<<x; 分隔符: io.putc('\n'); main() return 0; 前加 io.flush(); return 0;
2 回复
分享
发布于 2019-11-13 11:12

相关推荐

点赞 评论 收藏
转发
4 收藏 评论
分享
牛客网
牛客企业服务