C++ 读入优化(关闭输入输出流),从文件读数据,把数据输出到文件中

std::ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0); 


freopen("in.txt", "r", stdin);    //输入重定向,从文件 in.txt 中读入数据
freopen("out.txt", "w", stdout);     //输出重定向,输出数据将保存在out.txt文件中 
inline int read() {
    int f = 0, fu = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') fu = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}
发布了199 篇原创文章 · 获赞 156 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/Harington/article/details/100528647