Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- 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 sum = 0;
- for (int i = 0; i < n; i++) {
- sum += matrix[i][i];
- }
- cout << sum << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement