为什么???样例都对的,交上去全错,求助大佬。
  • 板块P1319 压缩技术
  • 楼主jh2023
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/9/2 19:54
  • 上次更新2023/11/2 23:48:34
查看原帖
为什么???样例都对的,交上去全错,求助大佬。
1043593
jh2023楼主2023/9/2 19:54

为什么???样例都对的,交上去全错,求助大佬。

#include <bits/stdc++.h>
using namespace std;
int a[210];
int main() {
	int n;
	cin >> n;
	int user;
	int total = 0;
	int count = 0;
	int num = 0;
	int sum = 0;
	while (total < n * n) {
		cin >> user;
		total += user;
		a[++num] = user;
	}
	/*cout << endl << endl;
	cout << "!";
	for (int i = 1; i <= num; i++) {
		cout << a[i] << endl;
	}
	cout << endl << endl;*/
	for (int i = 1; i <= num; i++) {
		if (i % 2 == 0) {
			for (int j = 1; j <= a[i]; j++) {
				cout << 1;
				sum++;
				if (sum == 49) {
					break;
				}
				if (sum % 7 == 0) {
					cout << endl;
				}
			}
		}
		else if (i % 2 != 0) {
			for (int j = 1; j <= a[i]; j++) {
				cout << 0;
				sum++;
				if (sum == 49) {
					break;
				}
				if (sum % 7 == 0) {
					cout << endl;
				}
				
			}
		}
	}
	return 0;
}

2023/9/2 19:54
加载中...