Advertisement
sazid_iiuc

Untitled

Jan 27th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. main()
  5. {
  6.     char in_arr[1000][1000];
  7.     int t, m,n, p=0;
  8.     cin>>t;
  9.  
  10.     for(int k=0; k<t; k++)
  11.     {
  12.         cin>>m>>n;
  13.         for(int i=0; i<m; i++)
  14.         {
  15.             for(int j=0; j<n; j++)
  16.             {
  17.                 cin>>in_arr[i][j];
  18.             }
  19.         }
  20.         for(int i=0; i<m; i++)
  21.         {
  22.             for(int j=0; j<n; j++)
  23.             {
  24.  
  25.                 if(in_arr[i][j]='*')
  26.                 {
  27.  
  28.                     in_arr[i-1][j-1]=p+1;
  29.                     in_arr[i-1][j]=p+1;
  30.                     in_arr[i-1][j+1]=p+1;
  31.                     in_arr[i][j-1]=p+1;
  32.                     in_arr[i][j+1]=p+1;
  33.                     in_arr[i+1][j-1]=p+1;
  34.                     in_arr[i+1][j]=p+1;
  35.                     in_arr[i+1][j+1]=p+1;
  36.                 }
  37.                 else
  38.                 {
  39.                     in_arr[i][j]=p;
  40.                 }
  41.                 cout<<in_arr[i][j]<<"\t";
  42.             }
  43.             cout<<endl;
  44.         }
  45.     }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement