快速輸入輸出模板

快速輸入輸出

indata() 輸入函數
outdata()輸出函數
在程序開頭結尾調用。
ggt()返回0/1的opt
poread()整形讀入
powrite()整形輸出帶換行git

namespace nfdata
{
const int BS = 1 << 24;
const int SB = 1 << 22;
char buf[BS], *st, *ed;
char fub[SB], *bg = fub;
inline void indata()
{
    ed = buf + fread(st = buf, 1, BS, stdin);
}
inline void outdata()
{
    fwrite(fub, 1, bg - fub, stdout);
}
inline unsigned char ggt()
{
	register unsigned char x;
	while(!isdigit(x = (*st++)));
	return x == '1';
}
template <typename Y>
inline void poread(Y &res)
{
    register int ret = 0;
    char ch;
    while (!isdigit(ch = (*st++)))
        ;
    do
        ret = ret * 10 + ch - '0';
    while (isdigit(ch = (*st++)));
    res = ret;
}
template <typename T>
inline void powrite(T x)
{
	if(x < 10)
	{
		*bg++ = x + '0';
		*bg++ = '\n';
		return;
	}
	static char s[10];
	sprintf(s,"%d\n",x);
    memcpy(bg, s, sizeof(s));
	register int len = strlen(s);
	bg += len;
}
} // namespace nfdata
using nfdata::powrite;
using nfdata::poread;
using nfdata::ggt;
相關文章
相關標籤/搜索