模板 输入输出优化

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