Advertisement
Josif_tepe

Untitled

Feb 15th, 2022
1,050
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. int main()
  9. {
  10.     int n, m;
  11.     cin >> n >> m;
  12.     int mat[n][m];
  13.    
  14.     for(int i = 0; i < n; i++) {
  15.         for(int j = 0; j < m; j++) {
  16.             cin >> mat[i][j];
  17.         }
  18.     }
  19.     for(int i = 0; i < n; i++) {
  20.         cout << mat[i][i] << " "; // glavna dijagonala
  21.     }
  22.     cout << endl;
  23.    
  24.     for(int i = 0; i < n; i++) {
  25.         cout << mat[i][n - 1 - i] << " "; // sporedna dijagonala
  26.     }
  27.     return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement