Josif_tepe

Untitled

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