我把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;
}