Code: Select all
Rempved after accepted! :D
Moderator: Board moderators
Code: Select all
Rempved after accepted! :D
Code: Select all
#include <iostream>
using namespace std;
int main()
{
int a,b,i,j,count=0;int arr[101][101];char carr[101][101];
while(1)
{cin>>a>>b;
if(!a && !b)
break;
count++;if(count>1){cout<<endl;}
for(i=1;i<=a;i++)
{
for(j=1;j<=b;j++)
{
char c;
cin>>c;
carr[i][j]=c;
if(c==42)
{
arr[i-1][j-1]++;
arr[i][j-1]++;
arr[i+1][j-1]++;
arr[i-1][j]++;
arr[i+1][j]++;
arr[i-1][j+1]++;
arr[i][j+1]++;
arr[i+1][j+1]++;
}
}
}
cout<<"Field #"<<count<<":"<<endl;
for(i=1;i<=a;i++)
{
for(j=1;j<=b;j++)
{
if(carr[i][j]==42)
cout<<"*";
else
cout<<arr[i][j];
}
cout<<endl;
}
for(i=0;i<=a+1;i++)
for(j=0;j<=b+1;j++)
{arr[i][j]=0;carr[i][j]='.';}
}
return 0;
}
Code: Select all
int arr[110][110];
char carr[110][110];
Code: Select all
for (i = 0 ; i <= row + 1; i++)
for (j = 0 ; j <= column + 1; j++)
array[i][j] = 0;