江清月近魂 • 11个月前
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int a[105][105] = {0};
for (int i = 0; i < 105; i++) {
for (int j = 0; j < 105; j++) {
a[i][j] = 0;
}
}
int r = 0, g = 0;
int sum = 0;
if (n == 1 && m == 1) {
cout << "1";
} else {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
r = 0;
if (a[i - 1][j] != 0) {
r++;
}
if (a[i + 1][j] != 0) {
r++;
}
if (a[i][j + 1] != 0) {
r++;
}
if (a[i][j - 1] != 0) {
r++;
}
sum = ((double)(a[i - 1][j]) + (double)(a[i + 1][j]) + (double)(a[i][j - 1]) + (double)a[i][j + 1] ) / r;
if (a[i][j] > sum) {
g++;
}
}
}
cout << g;
}
return 0;
}
© 2019 - 2023王码编程 滇ICP备19007937号-1
评论:
请先登录,才能进行评论