再次关于freopen
  • 板块学术版
  • 楼主ImposterAnYu
  • 当前回复6
  • 已保存回复6
  • 发布时间2021/8/4 10:32
  • 上次更新2023/11/4 12:03:47
查看原帖
再次关于freopen
510555
ImposterAnYu楼主2021/8/4 10:32

我把freopen那句注释掉后,我的控制台有输出;可是就算那个freopen没有注释,我的“2.in”依旧没有反应……

#include<bits/stdc++.h>
using namespace std;
int n,m,k,i,j;
bool xxx,yyy;
int main(){
	freopen("2.in","w",stdout);
	cin >> n >> m >> k;
	cout<< n << " " << m << " " << endl;
	srand((unsigned)time(NULL));
	for(i = 1; i <= n; i++){
		for(j = 1; j <= m; j++){
			char ch;
			int abc;
			if(!xxx && !yyy){
				abc = rand() % 4 + 1;
			}else if(!xxx){
				abc = rand() % 3 + 1;
			}else if(!yyy){
				while(abc == 3){
					abc = rand() % 4 + 1;
				}
			}else{
				abc = rand() % 2 + 1;
			}
			if(abc == 3){
				xxx = 1;
			}else if(abc == 4){
				yyy = 1;
			}
			ch = char(abc + 64);
			cout<< ch ;
		}
		cout<< endl;
	}
	for(i = 1; i <= k; i++){
		int a = rand() % n + 1,b = rand() % m + 1,c = rand() % (n + m) + 1;
		cout<< a << " " << b << " " << c << endl;
	}
	return 0;		
}
2021/8/4 10:32
加载中...