Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main(){
    int H,W;
    cin>>H>>W;
    string S;
    int A[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            A[i][j]=0;
        }
    }
    for(int i=0;i<H;i++){
        cin>>S;
        for(int j=0;j<W;j++){
            if(S[j]=='#'){
                A[i][j]+=9999;
                if(i==0){//上マスがない場合の処理
                    if(j==0){
                        A[0][1]++;
                        A[1][0]++;
                        A[1][1]++;
                    }else if(j==W-1){
                        A[0][j-1]++;
                        A[1][j]++;
                        A[1][j-1]++;
                    }else{
                        A[0][j-1]++;
                        A[0][j+1]++;
                        A[1][j-1]++;
                        A[1][j]++;
                        A[1][j+1]++;
                    }
                }else if(i==H-1){
                    if(j==0){
                        A[i][1]++;
                        A[i-1][0]++;
                        A[i-1][1]++;
                    }else if(j==W-1){
                        A[i][j-1]++;
                        A[i-1][j]++;
                        A[i-1][j-1]++;
                    }else{
                        A[i][j-1]++;
                        A[i][j+1]++;
                        A[i-1][j-1]++;
                        A[i-1][j]++;
                        A[i-1][j+1]++;
                    }
                }else{/
                    if(j==0){
                        A[i-1][j]++;
                        A[i-1][j+1]++;
                        A[i][j+1]++;
                        A[i+1][j]++;
                        A[i+1][j+1]++;
                    }else if(j==W-1){
                        A[i-1][j]++;
                        A[i-1][j-1]++;
                        A[i][j-1]++;
                        A[i+1][j]++;
                        A[i+1][j-1]++;
                    }else{
                        A[i-1][j-1]++;
                        A[i-1][j]++;
                        A[i-1][j+1]++;
                        A[i][j-1]++;
                        A[i][j+1]++;
                        A[i+1][j-1]++;
                        A[i+1][j]++;
                        A[i+1][j+1]++;
                    }
                }
            }
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(A[i][j]>=1000){
                cout<<'#';
            }else{
                cout<<A[i][j];
            }
            if(j==W-1){
                cout<<endl;
                break;
            }
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:23: error: expected primary-expression before '/' token
   58 |                 }else{/
      |                       ^
a.cc:59:21: error: expected primary-expression before 'if'
   59 |                     if(j==0){
      |                     ^~
a.cc:65:22: error: expected '}' before 'else'
   65 |                     }else if(j==W-1){
      |                      ^~~~
a.cc:58:22: note: to match this '{'
   58 |                 }else{/
      |                      ^
a.cc:65:22: error: expected '}' before 'else'
   65 |                     }else if(j==W-1){
      |                      ^~~~
a.cc:24:26: note: to match this '{'
   24 |             if(S[j]=='#'){
      |                          ^
a.cc: At global scope:
a.cc:84:5: error: expected declaration before '}' token
   84 |     }
      |     ^
a.cc:85:5: error: expected unqualified-id before 'for'
   85 |     for(int i=0;i<H;i++){
      |     ^~~
a.cc:85:17: error: 'i' does not name a type
   85 |     for(int i=0;i<H;i++){
      |                 ^
a.cc:85:21: error: 'i' does not name a type
   85 |     for(int i=0;i<H;i++){
      |                     ^
a.cc:98:5: error: expected unqualified-id before 'return'
   98 |     return 0;
      |     ^~~~~~
a.cc:99:1: error: expected declaration before '}' token
   99 | }
      | ^