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

模板 输入输出优化

时间:2020-02-12 14:50:36      阅读:57      评论:0      收藏:0      [点我收藏+]

标签:amp   read   getchar   write   tchar   char   put   turn   ret   

inline int read() {
    char ch, c=‘ ‘;
    int res;
    while (ch = getchar(), ch < ‘0‘ || ch>‘9‘) c = ch;
    res = ch - 48;
    while (ch = getchar(), ch >= ‘0‘ && ch <= ‘9‘) res = (res << 3) + (res << 1) + ch - 48;
    return c == ‘-‘ ? -res : res;
}

void write(int x) {
    if (x < 0)     putchar(‘-‘), x = -x;
    if (x > 9) write(x / 10);
    putchar(x % 10 + ‘0‘);
    return;
}
inline int read() {
    char ch, c;
    int res;
    while (ch = getchar(), ch < ‘0‘ || ch>‘9‘) c = ch;
    res = ch - 48;
    while (ch = getchar(), ch >= ‘0‘ && ch <= ‘9‘) res = (res << 3) + (res << 1) + ch - 48;
    return c == ‘-‘ ? -res : res;
}

void write(int x) {
    if (x < 0)     putchar(‘-‘), x = -x;
    if (x > 9) write(x / 10);
    putchar(x % 10 + ‘0‘);
    return;
}

 

模板 输入输出优化

标签:amp   read   getchar   write   tchar   char   put   turn   ret   

原文地址:https://www.cnblogs.com/hznumqf/p/12298936.html

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