Skip to content

Instantly share code, notes, and snippets.

@gonzalezfj
Created February 9, 2014 00:04
Show Gist options
  • Save gonzalezfj/8892241 to your computer and use it in GitHub Desktop.
Save gonzalezfj/8892241 to your computer and use it in GitHub Desktop.
#include<iostream>
using namespace std;
#define TOTAL 101
char tabla[TOTAL][TOTAL];
int tabla2[TOTAL][TOTAL];
int main() {
char n,m;
cout << "Ingrese las dimensiones\n";
cin>>n>>m;
int i,j;
char z = '0';
char string[TOTAL];
while (n !='0' && m !='0')
{
n = n - z;
m = m - z;
for (i= 1; i < n+1; i++)
{
cin >> string;
for (j = 1; j < m+1; j++)
{
tabla[i][j]=string[j];
if(string[j] == '*')
{
for (int x = -1; x <= 1; x++)
{
for (int c= -1; c <= 1; c++)
{
if(tabla[i + x][j + c] != '*')
{
tabla2[i + x][j + c]++;
}else
{
tabla2[i + x][j + c]= 9;
}
}
}
}
}
}
for (i= 1; i < n+1;i ++)
{
for (j = 1; j < m+1; j++)
{
cout << tabla2[i][j];
}
cout << endl;
}
cout << ("Ingrese las dimensiones\n");
for (i= 1; i < n+1; i++)
{
for (j = 1; j < m+1; j++)
{
tabla2[i][j]= 0;
}
}
cin>>n>>m;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment