func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 0x7fffffff;   const long double eps = 1e-8;   const int MAXN = 1111;   int n, m;   char g[MAXN][MAXN];   int col[MAXN][MAXN];   int sz[MAXN * MAXN];   char ans[MAXN][MAXN];   bool vis[MAXN][MAXN];   const int dx[4] = {-1, 0, 1, 0};   const int dy[4] = {0, 1, 0, -1};   int qx[MAXN * MAXN], qy[MAXN * MAXN];   void bfs(int x0, int y0) {     static int tot = 0;     ;     int l = 1, r = 1;     ++tot;     for (qx[1] = x0, qy[1] = y0, vis[x0][y0] = 1; l <= r; ++l) {       col[qx[l]][qy[l]] = tot;       for (int d = 0; d <= 3; ++d) {         int tx = qx[l] + dx[d];         int ty = qy[l] + dy[d];         if (tx > 0 && tx <= n && ty > 0 && ty <= m && !vis[tx][ty] &&             g[tx][ty] ==  . ) {           vis[tx][ty] = 1;           ++r;           qx[r] = tx;           qy[r] = ty;         }       }     }     sz[tot] = r;     ;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %s , g[i] + 1);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (g[i][j] ==  .  && !vis[i][j]) bfs(i, j);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (g[i][j] ==  . )           ans[i][j] =  . ;         else {           int p[4], t = 0, s = 1;           for (int d = 0; d <= 3; ++d) {             int tx = i + dx[d], ty = j + dy[d];             if (tx > 0 && tx <= n && ty > 0 && ty <= m && g[tx][ty] ==  . ) {               bool ok = 1;               for (int k = 0; k <= t - 1; ++k)                 if (p[k] == col[tx][ty]) {                   ok = 0;                   break;                 }               if (ok) {                 p[t++] = col[tx][ty];                 s += sz[col[tx][ty]];               }             }           }           ans[i][j] =  0  + s % 10;         }     for (int i = 1; i <= n; ++i) printf( %s n , ans[i] + 1);     return 0;   }   