Language: C++

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

int main(){
  int H,W,cnt1=0,cnt2=0;
  string len1,tmp;
  //入力フェイズ
  cin >> H >> W;
  for(int i=0;i<W;i++){
    cin >> tmp;
    len1+=tmp;
  }
  //出力フェイズ
  for(int i=0;i<H*W;i++){
    int k=0;
    //爆弾だったら
    if(len1.at(i*W+j)=='#'){
      cnt1=0;
      cnt2=0;
      cout << '#';
      continue;
     }
    k=-7;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
    k=-6;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
    k=-5;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
    k=-1;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
    k=1;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
    k=5;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
    k=6;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
    k=7;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
    cout << cnt << endl;
    cnt=0;
    cnt2++;
    if(cont2==W){
      cont2=0;
      cout << endl;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:20: error: 'j' was not declared in this scope
   17 |     if(len1.at(i*W+j)=='#'){
      |                    ^
a.cc:23:17: error: 'j' was not declared in this scope
   23 |     k=-7;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                 ^
a.cc:23:47: error: 'cnt' was not declared in this scope; did you mean 'cnt2'?
   23 |     k=-7;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                                               ^~~
      |                                               cnt2
a.cc:24:17: error: 'j' was not declared in this scope
   24 |     k=-6;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                 ^
a.cc:24:47: error: 'cnt' was not declared in this scope; did you mean 'cnt2'?
   24 |     k=-6;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                                               ^~~
      |                                               cnt2
a.cc:25:17: error: 'j' was not declared in this scope
   25 |     k=-5;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                 ^
a.cc:25:47: error: 'cnt' was not declared in this scope; did you mean 'cnt2'?
   25 |     k=-5;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                                               ^~~
      |                                               cnt2
a.cc:26:17: error: 'j' was not declared in this scope
   26 |     k=-1;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                 ^
a.cc:26:47: error: 'cnt' was not declared in this scope; did you mean 'cnt2'?
   26 |     k=-1;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                                               ^~~
      |                                               cnt2
a.cc:27:16: error: 'j' was not declared in this scope
   27 |     k=1;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                ^
a.cc:27:46: error: 'cnt' was not declared in this scope; did you mean 'cnt2'?
   27 |     k=1;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                                              ^~~
      |                                              cnt2
a.cc:28:16: error: 'j' was not declared in this scope
   28 |     k=5;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                ^
a.cc:28:46: error: 'cnt' was not declared in this scope; did you mean 'cnt2'?
   28 |     k=5;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                                              ^~~
      |                                              cnt2
a.cc:29:16: error: 'j' was not declared in this scope
   29 |     k=6;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                ^
a.cc:29:46: error: 'cnt' was not declared in this scope; did you mean 'cnt2'?
   29 |     k=6;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                                              ^~~
      |                                              cnt2
a.cc:30:16: error: 'j' was not declared in this scope
   30 |     k=7;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                ^
a.cc:30:46: error: 'cnt' was not declared in this scope; did you mean 'cnt2'?
   30 |     k=7;if(i*W+j+k>=0&&len1.at(i*W+j+k)=='#')cnt++;
      |                                              ^~~
      |                                              cnt2
a.cc:31:13: error: 'cnt' was not declared in this scope; did you mean 'cnt2'?
   31 |     cout << cnt << endl;
      |             ^~~
      |             cnt2
a.cc:34:8: error: 'cont2' was not declared in this scope; did you mean 'cnt2'?
   34 |     if(cont2==W){
      |        ^~~~~
      |        cnt2