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

fread优化读入

时间:2018-05-23 00:03:13      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:char   etc   ++   bool   while   ons   return   优化   stat   

inline char nc()
{
    static const int BS = 1 << 22;
    static unsigned char buf[BS],*st,*ed;
    if(st == ed) ed = buf + fread(st=buf,1,BS,stdin);
    return st == ed ? EOF : *st++;
}
//#define nc getchar
inline int read()
{
    char ch;
    int res = 0; bool flag = 0;
    while (!isdigit(ch = nc()));
    while (ch >= ‘0‘ and ch <= ‘9‘)
    {
        res = (res << 1) + (res << 3) + (ch - ‘0‘);
        ch = nc();
    }
    return res;
}

 

卡常

fread优化读入

标签:char   etc   ++   bool   while   ons   return   优化   stat   

原文地址:https://www.cnblogs.com/zZh-Brim/p/9074423.html

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