Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int SIZE = 6;
- int main() {
- int arr[SIZE][SIZE]{
- {0, 3, 9, 5, 7, 17},
- {1, 3, 4, 65, 9, 48},
- {1, 32, 4, 0, 6, 96},
- {7, 0, 4, 5, 53, 0},
- {0, 3, 4, 5, 73, 14},
- {1, 3, 4, 5, 74, 9},
- };
- //array output
- for (auto &i: arr) {
- for (int j: i)
- cout << " " << j;
- cout << endl;
- }
- int d1 = 0, d2 = SIZE - 1, sum = 0, sumAll = 0;
- for (int i = 0; i < sizeof(arr) / (SIZE * sizeof(int)); i++) {
- for (int j = 0; j < SIZE; j++) {
- if (j != d1 && j != d2) {
- sum += arr[i][j];
- }
- }
- cout << endl << "sum " << i + 1 << ": " << sum;
- sumAll += sum;
- sum = 0;
- d1++;
- d2--;
- }
- cout << endl << "\n\nSum All: " << sumAll;
- }
Advertisement
Add Comment
Please, Sign In to add comment