CSP、NOI 等比赛的数据重定向要求 ← freopen、fclose

【算法代码】

/*
设输入样例数据存在文件test.in中,输出样例数据存在文件test.out中,
则在CSP、NOI等比赛的代码中,需添加freopen、fclose语句,
内容详见模板代码如下。 
*/

#include <bits/stdc++.h>
using namespace std;

int main(){
	freopen("test.in","r",stdin);
	freopen("test.out","w",stdout);
	
	cout<<"Hello NOI"<<endl;
	
	fclose(stdin);
	fclose(stdout);
	
	return 0;
}

Guess you like

Origin blog.csdn.net/hnjzsyjyj/article/details/120577330