#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, m, i, j, k = 0;
while(cin >> n >> m && n != 0 && m != 0)
{
char ch[n+1][m+1];
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
cin >> ch[i][j];
}
}
if(k>0)
cout << endl;
int c;
cout << "Field #" << ++k << ":" <<endl;
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
if(ch[i][j] == '*')
{
cout << '*';
continue;
}
else
{
c = 0;
if(i-1 >=0 && j-1>=0 && ch[i-1][j-1] == '*')
{
c++;
}
if(i-1>=0 && ch[i-1][j] == '*')
{
c++;
}
if(i-1 >= 0 && j+1<m && ch[i-1][j+1] == '*')
{
c++;
}
if(j-1>=0 && ch[i][j-1] == '*')
{
c++;
}
if(j+1<m && ch[i][j+1] == '*')
{
c++;
}
if(i+1<n && ch[i+1][j] == '*')
{
c++;
}
if(i+1<n && j-1>=0 && ch[i+1][j-1] == '*')
{
c++;
}
if(i+1<n && j+1<m && ch[i+1][j+1] == '*' )
{
c++;
}
cout << c;
}
}
cout << endl;
}
}
return 0;
}
Comments
Post a Comment