文件读写

clion写代码的时候会有while(cin>>n)无法终止的问题

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

int main() {
    int a,b;
    freopen("./t.in","r",stdin);
    freopen("./t.out","w",stdout);
    while (cin>>a>>b)
        cout<<a+b<<endl;
    fclose(stdin);
    fclose(stdout);
    return 0;
}

这样写 , 提交时把文件读写去掉即可

posted @ 2025-05-10 22:47  Guaninf  阅读(4)  评论(0)    收藏  举报