Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int q, x, y, x2, y2, z, smen[103][103], v[103][103], m;
- int main()
- {
- int n;
- cout << "n=";
- cin >> n;
- cout << "m=";
- cin >> m;
- cout << "v:";
- for (int i = 1; i <= n; i++)
- for (int j = 1; j <= m; j++)
- cin >> v[i][j];
- cout << "q=";
- cin >> q;
- while (q--)
- {
- cin >> x >> y >> x2 >> y2 >> z;
- smen[x][y] += z;
- smen[x][y2 + 1] -= z;
- smen[x2 + 1][y] -= z;
- smen[x2 + 1][y2 + 1] += z;
- }
- for (int i = 1; i <= n; ++i)
- for (int j = 1; j <= m; j++)
- {
- smen[i][j] += smen[i - 1][j] + smen[i][j - 1] - smen[i - 1][j - 1];
- }
- for (int i = 1; i <= n; i++)
- for (int j = 1; j <= m; j++)
- {
- v[i][j] += smen[i][j];
- }
- cout << "after smen:" << endl;
- for (int i = 1; i <= n; i++)
- {
- for (int j = 1; j <=m; j++)
- cout << v[i][j] << ' ';
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement