Advertisement
Josif_tepe

Untitled

Aug 23rd, 2023
1,167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main(int argc, const char * argv[]) {
  4.     int n;
  5.     scanf("%d",&n);
  6.    
  7.     int mat[n][n];
  8.     for(int i = 0; i < n; i++) {
  9.         for(int j = 0; j < n; j++) {
  10.             scanf("%d", &mat[i][j]);
  11.         }
  12.     }
  13.    
  14.     for(int i = 0; i < n; i++) {
  15.         printf("%d\n", mat[i][n - 1 - i]);
  16.     }
  17.     // i = 0, n - i - 1 = 4 - 1 - 0 = 3
  18.     // i = 1, n - 1 - 1 = 4 - 2 = 2
  19.    
  20.     return 0;
  21.    
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement