输入优化与输出优化模板

读入优化模板

inline void read(int &x){
    int f = 1;
    x = 0;
    char s = getchar();
    while (s < '0' || s > '9'){
        if (s == '-')
            f = -1;
        s = getchar();
    }
    while (s >= '0' && s <= '9'){
        x = x * 10 + s - '0';
        s = getchar();
    }
    x *= f;
}

输出优化模板

inline void print(int x){
    if (x < 0){
        putchar('-');
        x = -x;
    }
    if (x > 9)
        print(x / 10);
    putchar(x % 10 + '0');
}

猜你喜欢

转载自blog.csdn.net/qq_43904786/article/details/84831758