Advertisement
Josif_tepe

Untitled

May 20th, 2021
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5.     int n, m;
  6.     scanf("%d%d", &n, &m);
  7.    
  8.     int matrica[n][m];
  9.     for(int i = 0; i < n; i++) {
  10.         for(int j = 0; j < m; j++) {
  11.             scanf("%d", &matrica[i][j]);
  12.         }
  13.     }
  14.    
  15.     for(int i = 0; i < n; i++) {
  16.         int pomosna = matrica[i][i];
  17.         matrica[i][i] = matrica[i][n - 1 - i];
  18.         matrica[i][n - 1 - i] = pomosna;
  19.     }
  20.    
  21.     for(int i = 0; i < n; i++) {
  22.         for(int j = 0; j < m; j++) {
  23.             printf("%d ", matrica[i][j]);
  24.         }
  25.         printf("\n");
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement