SHARE
TWEET

Untitled

a guest Sep 20th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. char mapa[1010][1010];
  6.  
  7. int main(){
  8.  
  9.     int m, n, costa = 0;
  10.  
  11.     cin >> m >> n;
  12.  
  13.     for(int i = 0; i <= n+1; i++){
  14.         for(int j = 0; j <= m+1; j++){
  15.             mapa[i][j] = '.';
  16.         }
  17.     }
  18.  
  19.     for(int i = 1; i <= m; i++){ // linha
  20.         for(int j = 1; j <= n; j++){ // coluna
  21.             cin >> mapa[i][j];          
  22.         }
  23.     }    
  24.  
  25.     for(int i = 1; i <= m; i++){ // linha
  26.         for(int j = 1; j <= n; j++){ // coluna
  27.             if(mapa[i][j] == '#'){
  28.  
  29.  
  30.                 if(mapa[i][j-1] == '.' || mapa[i][j+1] == '.' || mapa[i-1][j] == '.' || mapa[i+1][j] == '.'){
  31.                     costa++;
  32.                 }  
  33.             }
  34.  
  35.         }
  36.     }
  37.  
  38.     cout << costa << endl;
  39.     return 0;
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top