模板 输入输出优化

强颜欢笑 提交于 2020-02-12 14:59:52
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;
}

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!