简单题
View Code
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
#define maxn 15
char map[maxn][maxn];
char st[maxn];
int ans[maxn][maxn];
int n, m;
void input()
{
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++)
scanf("%s", map[i]);
}
void work()
{
for (int i = 0; i < n - 1; i++)
for (int j = 0; j < m - 1; j++)
ans[i][j] = (map[i][j] + map[i + 1][j] + map[i][j + 1] + map[i + 1][j + 1] - '0' * 4) / 4;
}
void print()
{
for (int i = 0; i < n - 1; i++)
{
for (int j = 0; j < m - 1; j++)
printf("%d", ans[i][j]);
putchar('\n');
}
}
int main()
{
//freopen("t.txt", "r", stdin);
while (scanf("%s", st), st[0] != 'E')
{
input();
work();
print();
scanf("%s", st);
}
return 0;
}