Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int m[7][7];
- int sumHourglass(int l, int c){
- int soma = 0;
- 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];
- return soma;
- }
- int main(){
- for(int i = 0; i < 6; i++){
- for(int j = 0; j < 6; j++){
- cin >> m[i][j];
- }
- }
- int ans = 0;
- for(int i = 0; i < 6; i++){
- for(int j = 0; j < 6; j++){
- if(i != 0 && j !=0 && i != 5 && j != 5){
- int aux = sumHourglass(i, j);
- //cout << "aux " << aux << endl;
- ans = max(ans, aux);
- //cout << "ans " << ans << endl;
- }
- }
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement