pastebin

Paste Search Dynamic
Recent pastes
amount
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 100;
  5.  
  6. int main() {
  7.     int n, m, nr_area, mt[MAX_SIZE + 1][MAX_SIZE + 1];
  8.     cin >> n >> m;
  9.     for (int i = 1; i <= n; ++i) {
  10.         for (int j = 1; j <= m; ++j) {
  11.             cin >> mt[i][j];
  12.         }
  13.     }
  14.     cin >> nr_area;
  15.     int i1, j1, i2, j2;
  16.     // we go through and read each area
  17.     for (int area = 1; area <= nr_area; ++area) {
  18.         cin >> i1 >> j1 >> i2 >> j2;
  19.                 int amount = 0;
  20.         //we go through the elements of the area and find their sum
  21.         for (int i = i1; i <= i2; ++i) {
  22.             for (int j = j1; j <= j2; ++j) {
  23.                 amount += mt[i][j];
  24.             }
  25.         }
  26.                 cout << "n";
  27.         cout << amount;
  28.         amount = 0;
  29.     }
  30.     return 0;
  31. }
Parsed in 0.011 seconds