关于freopen
  • 板块学术版
  • 楼主ImposterAnYu
  • 当前回复29
  • 已保存回复29
  • 发布时间2021/8/3 21:17
  • 上次更新2023/11/4 12:06:08
查看原帖
关于freopen
510555
ImposterAnYu楼主2021/8/3 21:17
#include<bits/stdc++.h>
using namespace std;
int n,m,k,i,j;
bool xxx,yyy;
int main(){
	freopen("1.in","w",stdout); 
	scanf("%lld%lld",&n,&m);
	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 + 16);
			cout<< ch ;
		}
		cout<< endl;
	}
	return 0;		
}

为什么运行了这个程序后,我的“1.in”没有任何变化?(freopen那一句我也不太会用,有错误麻烦说一下!)

2021/8/3 21:17
加载中...