#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
int a,b,t=0;
char c[500][500];
while(cin>>a>>b){
t++;
if(a==0&&b==0){
return 0;
}
if(t!=1){
cout<<endl;
}
for(int x=0;x<a;x++){
for(int y=0;y<b;y++){
cin>>c[x][y];
if(c[x][y]!='*'){
c[x][y]=c[x][y]+2;
}
}
}
cout<<"Field #"<<t<<":"<<endl;
for(int x=0;x<a;x++){
for(int y=0;y<b;y++){
if(c[x][y]=='*'){
for(int z=x-1;z<=x+1;z++){
for(int zz=y-1;zz<=y+1;zz++){
if(c[z][zz]!='*'&&z>=0&&zz>=0&&z<a&&zz<b){
c[z][zz]++;
}
}
}
}
}
}
for(int x=0;x<a;x++){
for(int y=0;y<b;y++){
if(c[x][y]!='*'){
cout<<c[x][y];
}else{
cout<<"*";
}
}
cout<<endl;
}
}
}
沒有留言:
張貼留言