Advertisement
STANAANDREY

suma in cub (14) 20pct

Dec 28th, 2021
1,257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. constexpr int NMAX = 53;
  4. int cube[NMAX][NMAX][NMAX], n;
  5.  
  6. void readCube() {
  7.     cin >> n;
  8.     for (int z = 1; z <= n; z++) {
  9.         for (int x = 1; x <= n; x++) {
  10.             for (int y = 1; y <= n; y++) {
  11.                 cin >> cube[z][x][y];
  12.             }
  13.         }
  14.     }
  15. }
  16.  
  17. signed main() {
  18.     readCube();
  19.     int x1, x2, y1, y2, z1, z2;
  20.     cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
  21.     int sum = 0;
  22.     for (int z = z1; z <= z2; z++) {
  23.         for (int x = x1; x <= x2; x++) {
  24.             for (int y = y1; y <= y2; y++) {
  25.                 sum += cube[z][x][y];
  26.             }
  27.         }
  28.     }
  29.     cout << sum << endl;
  30.     return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement