#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
int dx[8] = {-1,0,1,-1,1,-1,0,1};
int dy[8] = {-1,-1,-1,0,0,1,1,1};
int n;
cin >> n;
int a = 0;
vector <string> boom(n);
vector <string> check(n);
vector <string> find_boom(n,string(n,'.'));
for (int i = 0;i < n;i++) cin >> boom[i];
for (int i = 0;i < n;i++) cin >> check[i];
for (int i = 0;i < n;i++)
{
for (int j = 0;j < n;j++)
{
if (check[i][j] == 'x')
{
if(boom[i][j] == '*') a = 1;
else
{
int cnt = 0;
for (int k = 0;k < 8;k++)
{
int cnt = 0;//-_-boom[i+dy[k]][j+dx[k]]
// if (0 <= i+dy[k] < n && 0 <= j+dx[k] < n)
if (i + dy[k] >= 0 && i + dy[k] < n && j + dx[k] >= 0 && j + dx[k] < n)
{
cout << i + dy[k];
if (boom[i+dy[k]][j+dx[k]] == '*')
{
cnt++;
}
}
}
find_boom[i][j] = char(cnt + '0');
}
}
}
}
if (a)
{
for (int i = 0 ;i < n;i++)
{
for (int j = 0;j < n;j++)
{
if (boom[i][j] == '*')
{
find_boom[i][j] = '*';
}
}
}
}
for (int i = 0;i < n;i++)
{
for (int j = 0;j < n;j++)
{
cout << find_boom[i][j] << " ";
}
cout << "\n";
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: