Advertisement
vencinachev

K2Zad1

Dec 15th, 2020
767
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     const int MAX = 20;
  8.     int matrix[MAX][MAX];
  9.     int n;
  10.     do
  11.     {
  12.         cout << "Enter n: ";
  13.         cin >> n;
  14.     }
  15.     while (n < 1 || n > MAX);
  16.  
  17.     for (int i = 0; i < n; i++)
  18.     {
  19.         for (int j = 0; j < n; j++)
  20.         {
  21.             cin >> matrix[i][j];
  22.         }
  23.     }
  24.  
  25.  
  26.     for (int j = 0; j < n; j++)
  27.     {
  28.         for (int i = 0; i < j; i++)
  29.         {
  30.             cout << matrix[n - i - 1][j] << " ";
  31.         }
  32.         for (int i = j; i >= 0; i--)
  33.         {
  34.             cout << matrix[n - 1 - j][i] << " ";
  35.         }
  36.         cout << endl;
  37.     }
  38.  
  39.     cout << endl;
  40.     return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement