急!不会用freopen!现在考试提交不了
  • 板块灌水区
  • 楼主loseinlosing
  • 当前回复9
  • 已保存回复9
  • 发布时间2023/12/31 08:57
  • 上次更新2023/12/31 11:07:05
查看原帖
急!不会用freopen!现在考试提交不了
1097871
loseinlosing楼主2023/12/31 08:57

就是下面的代码,代码没问题,但一加上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; 
}
2023/12/31 08:57
加载中...