Advertisement
MeehoweCK

Untitled

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