Language: C++


#include <bits/stdc++.h>
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> mine(H);
  for (int i = 0; i < H; i++) {
    cin >> mine.at(i);
    
    for (int j = 0; j < W; j++) {
      
      if (mine.at(i).at(j) == '.') {
        mine.at(i).at(j) = '0';
      }
    }
  }     
    for(int l = 0; l < H; l++) {
      
      for (int m = 0; m < W; m++) {
        
        if(mine.at(l).at(m) == '#') {
        
          if(H != 1 && W != 1) {
            if(l != 0 && l != H - 1) {
            
              if(m != 0 && m != W -1) {
                for (int n = 0; n < 3; n++) {
                  for (int o = 0; o < 3; o++) {
                    if(mine.at(l - o + 1).at(m - n + 1) != '#') {
                      mine.at(l - o + 1).at(m - n + 1) += 1;
                    }
                  }
                }
              }
              else if (m == 0) {
                for (int p = 0; p < 2; p++) {
                  for (int q = 0; q < 3; q++) {
                    if(mine.at(l - q + 1).at(1 - p) != '#') {
                      mine.at(l - q + 1).at(1 - p) += 1;
                    }
                  } 
                } 
              }
              else if (m == W - 1) {
                for (int r = 0; r < 2; r++) {
                  for (int s = 0; s < 3; s++) {
                    if(mine.at(l - s + 1).at(W - r - 1) != '#') {
                            mine.at(l - s + 1).at(W - r - 1) += 1;
                    }
                  }
                }
              }
            }
            else if (l == 0) {
              if(m != 0 && m != W -1) {
                for (int t = 0; t < 3; t++) {
                  for (int u = 0; u < 2; u++) {
                    if(mine.at(1 - u).at(m - t + 1) != '#') {
                      mine.at(1 - u).at(m - t + 1) += 1;
                    }
                  }
                }
              }
              else if (m == 0) {
                for (int v = 0; v < 2; v++) {
                  for (int w = 0; w < 2; w++) {
                    if(mine.at(1 - w).at(1 - v) != '#') {
                      mine.at(1 - w).at(1 - v) += 1;
                    }
                  }
                }
              }
              else if (m == W - 1) {
                for (int x = 0; x < 2; x++) {
                  for (int y = 0; y < 2; y++) {
                    if(mine.at(1 - y).at(W - x - 1) != '#') {
                      mine.at(1 - y).at(W - x - 1) += 1;
                    }
                  }
                }
              }
            }
            else if (l == H - 1) {
              if(m != 0 && m != W -1) {
                for (int z = 0; z < 3; z++) {
                  for (int a = 0; a < 2; a++) {
                    if(mine.at(H - a - 1).at(m - z + 1) != '#') {
                      mine.at(H - a - 1).at(m - z + 1) += 1;
                    }
                  }
                }
              }
              else if (m == 0) {
                for (int b = 0; b < 2; b++) {
                  for (int c = 0; c < 2; c++) {
                    if(mine.at(H - c - 1).at(1 - b) != '#') {
                      mine.at(H - c - 1).at(1 - b) += 1;
                    }
                  }
                }
              }
              else if (m == W - 1) {
                for (int d = 0; d < 2; d++) {
                  for (int e = 0; e < 2; e++) {
                    if(mine.at(H - e - 1).at(W - d - 1) != '#') {
                      mine.at(H - e - 1).at(W - d - 1) += 1;
                    }
                  }
                }
              }
            }
          }
          else if (H == 1 && W != 1) {
            if (m != 0 && m != W - 1) {
              for (int f = 0; f < 3; f++) {
                if (mine.at(0).at(m - f + 1) != '#') {
                  mine.at(0).at(m - f + 1) += 1;
                }
              }
            }
            else if (m == 0) {
              for (int g = 0; g < 2; g++) {
                if (mine.at(0).at(1 - g) != '#') {
                  mine.at(0).at(1 - g) += 1;
                }
              }
            }
            else if (m == W - 1) {
              for (int h = 0; h < 2; h++) {
                if mine.at(0).at(W - h - 1) != '#') {
                      mine.at(0).at(W - h - 1) += 1;
                }
              }
            }
          }
          else if (H != 1 && W == 1) {
            if (l != 0 && l != H - 1) {
              for (int aa = 0; aa < 3; aa++) {
                if (mine.at(l - aa + 1).at(0) != '#') {
                  mine.at(l - aa + 1).at(0) += 1;
                }
              }
            }
            else if (l == 0) {
              for (int ab = 0; ab < 2; ab++) {
                if (mine.at(1 - ab).at(0) != '#') {
                  mine.at(1 - ab).at(0) += 1;
                }
              }
            }
            else if (l == H - 1) {
              for (int ac = 0; ac < 2; ac++) {
                if mine.at(H - ac - 1).at(0) != '#') {
                      mine.at(H - ac - 1).at(0) += 1;
                }
              }
            }
          }
        }
      }
    }
    for (int k = 0; k < H; k++) {
    cout << mine.at(k) << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:132:20: error: expected '(' before 'mine'
  132 |                 if mine.at(0).at(W - h - 1) != '#') {
      |                    ^~~~
      |                    (
a.cc:155:20: error: expected '(' before 'mine'
  155 |                 if mine.at(H - ac - 1).at(0) != '#') {
      |                    ^~~~
      |                    (