怎么用文件输出啊

tctm132 睿智 2023-05-27 19:38:43 0

很多题本来呢能过样例,但没用文件输出,CE......

{{ vote && vote.total.up }}

共 3 条回复

tctm132 睿智

谢谢老师

root 站长

比如这道题目, [#2035. 「NOIP 2007 普及组」奖学金](/problem/2035),在main函数最前面写文件操作,具体如下:

#include <bits/stdc++.h>

using namespace std;

int main()
{
    //文件操作
    freopen ("scholar.in", "r", stdin); 
    freopen ("scholar.out", "w", stdout);
    
    //后面再写你的正常的代码,main函数之外不受影响。
    rerturn 0;
}
root 站长

freopen("输入文件名", "r", stdin); freopen("输出文件名", "w", stdout);