社区讨论

求助大佬!!

学术版参与者 2已保存回复 6

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
6 条
当前快照
1 份
快照标识符
@lt1g7hiz
此快照首次捕获于
2024/02/25 19:50
2 年前
此快照最后确认于
2024/02/25 22:39
2 年前
查看原帖
CPP
#include<bits/stdc++.h>
using namespace std;
int x;
string s;
int main()
{
	srand(time(0));
	fstream file;
	file.open("submit.txt",ios::in|ios::out);
	cin>>x;
	if(!file.is_open())
	{
		cout<<"Worring ! We can't open the file !";
		exit(1);
	}
	int flag=0;
	while(!file.eof())
	{
		file >> s;
		getline (file,s);
                cout<<s;
		if(flag==1)
		{
			flag++;
		}
		if(s.find("main")!=-1)
		{
			flag=1;
		} 
		if(file.is_open())
		{
			file << s;
		}
		else
		{
			cout<<"Worring ! We can't open the file !";
			exit(1);
		}
		if(flag==2)
		{
			file << "freopen(\"in.txt\",\"r\",stdin);"; 
			file << "freopen(\"out.txt\",\"w\",stdout);"; 
		}
	}
	file.close();
}
有没有大佬帮帮我,无论submit.txt怎么改,都不会输出

回复

6 条回复,欢迎继续交流。

正在加载回复...