Advertisement
realanton12345

Task 2

Dec 28th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <iomanip>
  5. #include <ctime>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     cout << "LR5" << endl;
  12.     int m;
  13.     cout << "Enter the size of an array: ";
  14.     cin >> m;
  15.  
  16.     int **arr = new int*[m];
  17.     for (int i = 0; i < m; i++) {
  18.         arr[i] = new int[m];
  19.     }
  20.  
  21.     srand(time(NULL));
  22.  
  23.     cout << "Generated array: " << endl;
  24.     for (int i = 0; i < m; i++) {
  25.         for (int j = 0; j < m; j++) {
  26.             arr[i][j] = rand() % 10 + 1;
  27.             cout << setw(3) << arr[i][j];
  28.         }
  29.         cout << endl;
  30.     }
  31.  
  32.     bool s = true;
  33.  
  34.     for (int i = 0; i < m; i++) {
  35.         for (int j = 0; j < m - i; j++) {
  36.             if (arr[i][j] != arr[m - j - 1][m - i - 1]) {
  37.                 s = false;
  38.                 break;
  39.             }
  40.         }
  41.     }
  42.  
  43.     if (!s) {
  44.         cout << "No";
  45.     } else {
  46.         cout << "Yes";
  47.     }
  48.  
  49.     system("pause");
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement