首页 > 其他 > 详细

模板 输入输出优化

时间:2020-02-12 14:55:22      阅读:72      评论:0      收藏:0      [点我收藏+]
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;
}

 

模板 输入输出优化

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

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