就是下面的代码,代码没问题,但一加上freopen就显示运行时程序出错
#include<bits/stdc++.h>
using namespace std;
int gz[100000];
int main() {
freopen("stick.in","r",stdin);
freopen("stick.out","w",stdout);
int n, max1 = 0;
scanf("%d", &n);
for(int i = 0; i < n; i++){
scanf("%d", &gz[i]);
max1 = max(max1, gz[i]);
}
for(int i = 0; i < max1; i++){
for(int j = 0; j < n; j++)
if(gz[j]){
printf("|");
gz[j]--;
}
else
printf(" ");
printf("\n");
}
return 0;
}