10分,求调。
查看原帖
10分,求调。
1414693
vvvsc03楼主2025/8/29 19:14
#include <bits/stdc++.h>
using namespace std;

/*你已经入以及战备状态,加油伞兵*/
int main() {
	int n, m;
	cin >> n >> m;
	int a[n][m] = {0};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (a[i][j] == 1) {
				if (a[i][j + 1] == 1) {
					if (a[i + 1][j] == 1) {
						if (a[i + 1][j + 1] == 1) {
							cnt++;
						}
					}
				}
			}
		}
	}
	cout << cnt << endl;

	return 0;
}

2025/8/29 19:14
加载中...