Advertisement
MeehoweCK

Untitled

Nov 23rd, 2020
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     //ios_base::sync_with_stdio(0);
  7.     short n,m;
  8.     cin>>n>>m;
  9.     short kw[n][m];
  10.     for(short x=0; x<n; x++)
  11.     {
  12.         for(short z=0; z<m; z++)
  13.         {
  14.             cin>>kw[x][z];
  15.         }
  16.     }
  17.  
  18.     int q;
  19.     short a1,b1,a2,b2;
  20.     int suma=0;
  21.     cin>>q;
  22.     for(int z=0; z<q; z++)
  23.     {
  24.         cin>>a1>>b1>>a2>>b2;
  25.  
  26.         for(short i = a1 - 1; i < a2; ++i)
  27.             for(short j = b1 - 1; j < b2; ++j)
  28.                 suma += kw[i][j];
  29.  
  30.         cout<<suma<<'\n';
  31.         suma=0;
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement