StoneHaos

dima17

Apr 29th, 2020
328
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int main(void) {
  6.     srand(time(NULL));
  7.     int n;
  8.     scanf("%d", &n);
  9.     int **a = new int*[n], **b = new int*[n];
  10.     for (int i = 0; i < n; ++ i) {
  11.         a[i] = new int[n];
  12.         for (int j = 0; j < n; ++ j) {
  13.             a[i][j] = rand() % 100;
  14.             printf("%4d ", a[i][j]);
  15.         }
  16.         printf("\n");
  17.     }
  18.     printf("\n\n");
  19.     for (int i = 0; i < n; ++ i) {
  20.         b[i] = new int[n];
  21.         for (int j = 0; j < n; ++ j) {
  22.             if (i == n - j - 1)
  23.                 b[i][j] = a[i][j];
  24.             else
  25.                 b[i][j] = a[n - j - 1][n - i - 1];
  26.             printf("%4d ", b[i][j]);
  27.         }
  28.         printf("\n");
  29.     }
  30.     for (int i = 0; i < n; ++ i) {
  31.         delete [] a[i];
  32.         delete [] b[i];
  33.     }
  34.     delete [] a;
  35.     delete [] b;
  36.     return 0;
  37. }
RAW Paste Data