Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n ;
  int w;
  cin >> n >> w;
  int ans = 1;
  char list[n][w];
  for(int i = 0; i < n; i++){
    string s;
    getline(cin, s);
    for(int j = 0; j < w; j++){
      list[i][j] = s.at(j);
    }
  }
  
  for(int i = 0; i < n; i++){
    if( i == 0 ) {
      for(int j = 0; j < w; j++){    
        int num = 0;
        if(j == 0) {
			if(list[i+1][j] == "#")num++;      
			if(list[i][j+1] == "#")num++;      
			if(list[i+1][j+1] == "#")num++;      
        } else if (j < w-2) {
			if(list[i][j+1] == "#")num++;      
			if(list[i][j-1] == "#")num++;      
			if(list[i+1][j-1] == "#")num++;
          	if(list[i+1][j] == "#")num++;      
			if(list[i+1][j+1] == "#")num++;         
        } else if (j == w-1) {
			if(list[i][j-1] == "#")num++;      
			if(list[i+1][j-1] == "#")num++;      
			if(list[i+1][j] == "#")num++;            
        }
        if(list[i][j] != "#") list[i][j] = (char)num;
      }	
      
    } else if (i < n-2) {
      for(int j = 0; j < w; j++){    
        int num = 0;
        if(j == 0) {
      		if(list[i-1][j] == "#")num++;      
			if(list[i-1][j+1] == "#")num++;      
			if(list[i][j+1] == "#")num++;
          	if(list[i+1][j] == "#")num++;      
			if(list[i+1][j+1] == "#")num++;         
        } else if (j < w-2) {
			if(list[i-1][j-1] == "#")num++;      
			if(list[i-1][j] == "#")num++;   
   			if(list[i-1][j+1] == "#")num++;      
			if(list[i][j-1] == "#")num++;
          	if(list[i][j+1] == "#")num++;      
			if(list[i+1][j-1] == "#")num++;         
			if(list[i+1][j] == "#")num++;         
			if(list[i+1][j+1] == "#")num++;         
        } else if (j == w-1) {
          if(list[i-1][j-1] == "#")num++;      
			if(list[i-1][j] == "#")num++;      
			if(list[i][j-1] == "#")num++;
          	if(list[i+1][j-1] == "#")num++;      
			if(list[i+1][j] == "#")num++;         
        }
        if(list[i][j] != "#") list[i][j] = (char)num;
      }	
    
    } else if (i == n-1){
      for(int j = 0; j < w; j++){    
        int num = 0;
        if(j == 0) {
			if(list[i-1][j] == "#")num++;      
			if(list[i-1][j+1] == "#")num++;      
			if(list[i][j+1] == "#")num++;            
        } else if (j < w-2) {
			if(list[i-1][j-1] == "#")num++;      
			if(list[i-1][j] == "#")num++;      
			if(list[i-1][j+1] == "#")num++;                  
			if(list[i][j-1] == "#")num++;      
			if(list[i][j+1] == "#")num++;      
        } else if (j == w-1) {
			if(list[i-1][j-1] == "#")num++;      
			if(list[i-1][j] == "#")num++;      
			if(list[i][j-1] == "#")num++;            
      
        }
        if(list[i][j] != "#") list[i][j] = (char)num;      
      }	
    }
  }

   for(int i = 0; i < n; i++){
      for(int j = 0; j < w; j++){
      cout >> list[i][j];
      }
      cout >> endl;
   }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   23 |                         if(list[i+1][j] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:24:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   24 |                         if(list[i][j+1] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:25:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   25 |                         if(list[i+1][j+1] == "#")num++;
      |                            ~~~~~~~~~~~~~~~^~~~~~
a.cc:27:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   27 |                         if(list[i][j+1] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:28:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   28 |                         if(list[i][j-1] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:29:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   29 |                         if(list[i+1][j-1] == "#")num++;
      |                            ~~~~~~~~~~~~~~~^~~~~~
a.cc:30:33: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   30 |                 if(list[i+1][j] == "#")num++;
      |                    ~~~~~~~~~~~~~^~~~~~
a.cc:31:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   31 |                         if(list[i+1][j+1] == "#")num++;
      |                            ~~~~~~~~~~~~~~~^~~~~~
a.cc:33:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   33 |                         if(list[i][j-1] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:34:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   34 |                         if(list[i+1][j-1] == "#")num++;
      |                            ~~~~~~~~~~~~~~~^~~~~~
a.cc:35:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   35 |                         if(list[i+1][j] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:37:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   37 |         if(list[i][j] != "#") list[i][j] = (char)num;
      |            ~~~~~~~~~~~^~~~~~
a.cc:44:33: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   44 |                 if(list[i-1][j] == "#")num++;
      |                    ~~~~~~~~~~~~~^~~~~~
a.cc:45:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   45 |                         if(list[i-1][j+1] == "#")num++;
      |                            ~~~~~~~~~~~~~~~^~~~~~
a.cc:46:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   46 |                         if(list[i][j+1] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:47:33: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   47 |                 if(list[i+1][j] == "#")num++;
      |                    ~~~~~~~~~~~~~^~~~~~
a.cc:48:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   48 |                         if(list[i+1][j+1] == "#")num++;
      |                            ~~~~~~~~~~~~~~~^~~~~~
a.cc:50:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   50 |                         if(list[i-1][j-1] == "#")num++;
      |                            ~~~~~~~~~~~~~~~^~~~~~
a.cc:51:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   51 |                         if(list[i-1][j] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:52:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   52 |                         if(list[i-1][j+1] == "#")num++;
      |                            ~~~~~~~~~~~~~~~^~~~~~
a.cc:53:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   53 |                         if(list[i][j-1] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:54:33: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   54 |                 if(list[i][j+1] == "#")num++;
      |                    ~~~~~~~~~~~~~^~~~~~
a.cc:55:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   55 |                         if(list[i+1][j-1] == "#")num++;
      |                            ~~~~~~~~~~~~~~~^~~~~~
a.cc:56:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   56 |                         if(list[i+1][j] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:57:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   57 |                         if(list[i+1][j+1] == "#")num++;
      |                            ~~~~~~~~~~~~~~~^~~~~~
a.cc:59:29: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   59 |           if(list[i-1][j-1] == "#")num++;
      |              ~~~~~~~~~~~~~~~^~~~~~
a.cc:60:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   60 |                         if(list[i-1][j] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:61:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   61 |                         if(list[i][j-1] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:62:35: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   62 |                 if(list[i+1][j-1] == "#")num++;
      |                    ~~~~~~~~~~~~~~~^~~~~~
a.cc:63:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   63 |                         if(list[i+1][j] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:65:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   65 |         if(list[i][j] != "#") list[i][j] = (char)num;
      |            ~~~~~~~~~~~^~~~~~
a.cc:72:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   72 |                         if(list[i-1][j] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:73:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   73 |                         if(list[i-1][j+1] == "#")num++;
      |                            ~~~~~~~~~~~~~~~^~~~~~
a.cc:74:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   74 |                         if(list[i][j+1] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:76:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   76 |                         if(list[i-1][j-1] == "#")num++;
      |                            ~~~~~~~~~~~~~~~^~~~~~
a.cc:77:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   77 |                         if(list[i-1][j] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:78:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   78 |                         if(list[i-1][j+1] == "#")num++;
      |                            ~~~~~~~~~~~~~~~^~~~~~
a.cc:79:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   79 |                         if(list[i][j-1] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:80:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   80 |                         if(list[i][j+1] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:82:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   82 |                         if(list[i-1][j-1] == "#")num++;
      |                            ~~~~~~~~~~~~~~~^~~~~~
a.cc:83:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   83 |                         if(list[i-1][j] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:84:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   84 |                         if(list[i][j-1] == "#")num++;
      |                            ~~~~~~~~~~~~~^~~~~~
a.cc:87:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   87 |         if(list[i][j] != "#") list[i][j] = (char)num;
      |            ~~~~~~~~~~~^~~~~~
a.cc:94:12: error: no match for 'operator>>' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'char')
   94 |       cout >> list[i][j];
      |       ~~~~ ^~ ~~~~~~~~~~
      |       |                |
      |       |                char
      |       std::ostream {aka std::basic_ostream<char>}
a.cc:94:12: note: candidate: 'operator>>(int, int)' (built-in)
   94 |       cout >> list[i][j];
      |       ~~~~~^~~~~~~~~~~~~
a.cc:94:12: note:   no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int'
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41,
                 from a.cc:1:
/usr/include/c++/14/cstddef:131:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(byte, _IntegerType)'
  131 |     operator>>(byte __b, _IntegerType __shift) noexcept
      |     ^~~~~~~~
/usr/include/c++/14/cstddef:131:5: note:   template argument deduction/substitution failed:
a.cc:94:7: note:   cannot convert 'std::cout' (type 'std::ostream' {aka 'std::basic_ostream<char>'}) to type 'std::byte'
   94 |       cout >> list[i][j];
      |       ^~~~
In file included from /usr/include/c++/14/string:55,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: candidate: 'template<class _