码迷,mamicode.com
首页 > 其他好文 > 详细

快速IO

时间:2019-08-14 21:52:17      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:template   fread   int   read   while   快速   for   line   -o   

namespace IO {
#define gc() (iS==iT?(iT=(iS=ibuff)+fread(ibuff,1,SIZ,stdin),(iS==iT?EOF:iS++)):iS++)
const int SIZ = 1 << 21 | 1;
char iS,iT,ibuff[SIZ],obuff[SIZ],oS = obuff,oT=oS+SIZ-1,fu[110],c;int fr;
inline void out() {
fwrite(obuff,1,oS-obuff,stdout);
oS=obuff;
}
template
inline void read(Type &x) {
x=0;Type y=1;
for(c=gc();(c>‘9‘||c<‘0‘)&&c!=‘-‘;c=gc());
c==‘-‘?y=-1:x=(c&15);
for(c=gc();c>=‘0‘&&c<=‘9‘;c = gc())x = x * 10 + (c & 15);
x=y;
}
template
inline void write(Type x) {
if(x<0)
oS++=‘-‘,x=-1;
if(x==0)
oS++=‘0‘;
while(x) fu[++fr]=x%10+‘0‘,x/=10;
while(fr) oS++=fu[fr--];
oS++=‘\n‘;
out();
}
}

快速IO

标签:template   fread   int   read   while   快速   for   line   -o   

原文地址:https://www.cnblogs.com/zhenglier/p/11354688.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!