func_code_string: #include <bits/stdc++.h>   using namespace std;   int x, y;   char a[1001][1001];   int n, c[1000000], ni[5001][5001];   bool vis[1001][1001], b[1000000];   int e[] = {1, -1, 0, 0};   int r[] = {0, 0, -1, 1};   void dfs(int i, int j, int n) {     vis[i][j] = true;     ni[i][j] = n;     c[n]++;     for (int g = 0; g < 4; g++) {       int z = i + e[g], k = j + r[g];       if (a[z][k] ==  .  && z >= 0 && z < x && k >= 0 && k < y &&           vis[z][k] == false)         dfs(z, k, n);     }   }   int main() {     scanf( %d%d , &x, &y);     for (int i = 0; i < x; i++) scanf( %s , &a[i]);     int g = 1;     for (int i = 0; i < x; i++) {       for (int j = 0; j < y; j++) {         if (a[i][j] ==  .  && vis[i][j] == false) {           dfs(i, j, g);           g++;         }       }     }     for (int i = 0; i < x; i++) {       for (int j = 0; j < y; j++) {         if (a[i][j] ==  * ) {           int sum = 1;           for (int k = 0; k < 4; k++) {             int z = i + e[k], d = j + r[k];             if (a[z][d] ==  .  && b[ni[z][d]] == false && z >= 0 && z < x &&                 d >= 0 && d < y) {               sum += c[ni[z][d]];               b[ni[z][d]] = true;             }           }           a[i][j] = sum % 10 + 48;           for (int k = 0; k < 4; k++) {             int z = i + e[k], d = j + r[k];             if (z >= 0 && z < x && d >= 0 && d < y && a[z][d] ==  . ) {               b[ni[z][d]] = false;             }           }         }       }     }     for (int i = 0; i < x; i++) {       for (int j = 0; j < y; j++) {         printf( %c , a[i][j]);       }       cout << endl;     }   }   