#include<iostream> usingnamespace std; intcc(int **matp, int m, int l, int h); intmain() { int m, n, l, h; cin >> m >> n; int **matp = newint*[m]; for (int i = 0; i < m; i++) { *(matp + i) = newint[n]; } for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { cin >> matp[i][j]; } } cin >> l >> h; int max = 0; int temp = 0; for (int i = 0; i < m-l+1; i++) { for (int j = 0; j < n-h+1; j++) { temp = cc(matp + i, j, l, h); max = (temp >= max) ? temp : max; } } cout << max; return0; } intcc(int **matp, int xa, int l, int h) { int ret = 0; for (int i = 0; i < l; i++) { for (int j = 0; j < h; j++) { ret += matp[i][j + xa]; } } return ret; }
Read our privacy policy on how these personalized advertisements are
delivered to you.
For your reading experience, we provide full-text RSS feeds.
Although math formulas cannot be displayed well, the interface can be adjusted as you like
and there are no ads.
#include<iostream> usingnamespace std; intcc(int **matp, int m, int l, int h); intmain() { int m, n, l, h; cin >> m >> n; int **matp = newint*[m]; for (int i = 0; i < m; i++) { *(matp + i) = newint[n]; } for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { cin >> matp[i][j]; } } cin >> l >> h; int max = 0; int temp = 0; for (int i = 0; i < m-l+1; i++) { for (int j = 0; j < n-h+1; j++) { temp = cc(matp + i, j, l, h); max = (temp >= max) ? temp : max; } } cout << max; return0; } intcc(int **matp, int xa, int l, int h) { int ret = 0; for (int i = 0; i < l; i++) { for (int j = 0; j < h; j++) { ret += matp[i][j + xa]; } } return ret; }
Read our privacy policy on how these personalized advertisements are
delivered to you.
For your reading experience, we provide full-text RSS feeds.
Although math formulas cannot be displayed well, the interface can be adjusted as you like
and there are no ads.