首页 > 其他 > 详细

输入挂

时间:2015-08-17 21:52:00      阅读:181      评论:0      收藏:0      [点我收藏+]

输入挂,原理是把文件里面的东西用fread一次性读到内存。
使用时必须 #include “cctype”, 先调用 IO:init(); 然后全部用 IO:readint() 读入数据;

namespace IO {
    const static int maxn = 200 << 20;
    static char buf[maxn], *pbuf = buf, *End;
    void init() {
        int c = fread(buf, 1, maxn, stdin);
        End = buf + c;
    }
    int &readint() {
        static int ans;
        ans = 0;
        while (pbuf != End && !isdigit(*pbuf)) pbuf ++;
        while (pbuf != End && isdigit(*pbuf)) {
            ans = ans * 10 + *pbuf - ‘0‘;
            pbuf ++;
        }
        return ans;
    }
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

输入挂

原文:http://blog.csdn.net/kl28978113/article/details/47731691

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!