#include<stdio.h>
int main(){
int a, b, time = 1;
while (scanf("%d%d", &a, &b) != EOF){
if (a == 0 && b == 0)break;
int i = 0, j = 0;
char mine[201][201];
for (i = 0; i <= a + 1; i++)/*初始化*/
for (j = 0; j <= b + 1; j++)
mine[i][j] = '0';
for (i=0; i < a; i++){/*輸入每列字串*/
scanf("%s", mine[i]);
}
if (time>1) puts(""); /*Field #x之間換行*/
printf("Field #%d:\n", time++);
for (i = 0; i < a; i++){
for (j = 0; j < b; j++){
if (mine[i][j] == '*'){
printf("*");
continue;
}
int count = 0;/*計算4周的炸彈數量*/
if (mine[i - 1][j - 1] == '*') count++;
if (mine[i - 1][j] == '*') count++;
if (mine[i - 1][j + 1] == '*') count++;
if (mine[i][j - 1] == '*') count++;
if (mine[i][j + 1] == '*') count++;
if (mine[i + 1][j - 1] == '*') count++;
if (mine[i + 1][j] == '*')count++;
if (mine[i + 1][j + 1] == '*') count++;
printf("%d", count);
}
puts("");/*一列跑完換行*/
}
}
return 0;
}
留言
張貼留言