Advertisement
Guest User

xxxxx

a guest
Dec 5th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int m[7][7];
  7.  
  8. int sumHourglass(int l, int c){
  9.  
  10.     int soma = 0;
  11.     soma = m[l-1][c-1] + m[l-1][c] + m[l-1][c+1] + m[l][c] + m[l+1][c-1] + m[l+1][c] + m[l+1][c+1];
  12.  
  13.     return soma;
  14. }
  15.  
  16. int main(){
  17.    
  18.     for(int i = 0; i < 6; i++){
  19.         for(int j = 0; j < 6; j++){
  20.  
  21.             cin >> m[i][j];
  22.  
  23.         }
  24.     }
  25.  
  26.     int ans = 0;
  27.  
  28.     for(int i = 0; i < 6; i++){
  29.         for(int j = 0; j < 6; j++){
  30.  
  31.             if(i != 0 && j !=0 && i != 5 && j != 5){
  32.                 int aux = sumHourglass(i, j);  
  33.                 //cout << "aux " << aux << endl;              
  34.                 ans = max(ans, aux);    
  35.                 //cout << "ans " << ans << endl;            
  36.             }
  37.  
  38.         }
  39.     }
  40.  
  41.     cout << ans << endl;
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement