源于谋篇博主博文,写到利用freopen的语法和enif结合,各大oj上面都有相关的记录。文件的离线处理
freopen(“in.txt”,”r”,stdin); freopen(“out.txt”,”w”,stdout);
需要注意的是,算法选手可以使用文件夹然后把同一道题面的所有input和output以及代码放到一起。
注意提交代码的时候注释
所以这里提供另外一种不需要选手进行注释的写法
#include<bits/stdc++.h>
using namespace std;
int main() {
#ifdef ONLINE_JUDGE
#else
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
return 0;
}
//使用这个写法不需要注释各大oj预编译处理过