Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- int mat[n][n];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- cin >> mat[i][j];
- }
- }
- // glavna dijagonala
- int zbir = 0;
- for(int i = 0; i < n; i++) {
- zbir += mat[i][i];
- }
- // sporedna dijagonala
- int zbir_sporedna = 0;
- for(int i = 0; i < n; i++) {
- zbir_sporedna += mat[i][n - 1 - i];
- }
- cout << zbir << endl;
- cout << zbir_sporedna << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement