Created
February 9, 2014 00:04
-
-
Save gonzalezfj/8892241 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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