Código C++:
Ver original
void actualizar(char a[][p], int l, int f, int c) { if(l < 2 || l > 3) { a[f][c] = '0';} if(l == 2 || l == 3) { a[f][c] = '1';} } void ng(char a [][p], int l) { int f,c; for(f = 0; f < d; f++){ for(c = 0; c < p; c++) { if(a[f][c] != ' ') { if(f > 0 && c > 0){ if(a[f-1] [c-1] != ' ') {l++;}} if(f > 0) { if(a[f-1] [c] != ' ') {l++;}} if(f > 0 && c < p) { if(a [f-1] [c+1] != ' ') {l++;}} if(c > 0) { if(a [f][c-1] != ' ') {l++;}} if(c < p) { if(a [f][c+1] != ' ') {l++;}} if(f < d && c > 0){ if(a[f+1] [c-1] != ' ') {l++;}} if(f < d) { if(a [f + 1] [c] != ' ') {l++;}} if(f < d && c < p) { if(a [f + 1] [c + 1] != ' ') {l++;}}} actualizar(a, l, f, c); l = 0; }}