现在的位置: 首页 > 综合 > 正文

ACM C++读写外挂模板 读写优化

2018年05月01日 ⁄ 综合 ⁄ 共 226字 ⁄ 字号 评论关闭

有一些极端情况,用scanf会超时,用putchar

下面为读数字

void nextInt(int &x) //输入外挂
{
    do c=getchar(); while (c<'0'||c>'9');
    x=c-'0';
    while ('0'<=(c=getchar())&&c<='9') x=x*10+c-'0';
}

void Out(int a)    //输出外挂
{
	if(a>9)
    Out(a/10);
	putchar(a%10+'0');
}

参考:

poj 1904(强连通分量+输入输出外挂)

抱歉!评论已关闭.