Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cmath>
- using namespace std;
- int main() {
- int n, el;
- cin >> n;
- vector<vector<int>> matrix;
- for (int i = 0; i < n; i++) {
- vector<int> currentRow;
- for (int j = 0; j < n; j++) {
- cin >> el;
- currentRow.push_back(el);
- }
- matrix.push_back(currentRow);
- }
- int diff = 0;
- for (int i = 0; i < n; i++) {
- diff += matrix[i][i];
- }
- for (int i = 0; i < n; i++) {
- diff -= matrix[i][n - (1 + i)];
- }
- cout << abs(diff) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement