Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <time.h>
- #include <iomanip>
- #include <ctime>
- using namespace std;
- int main()
- {
- cout << "LR5" << endl;
- int m;
- cout << "Enter the size of an array: ";
- cin >> m;
- int **arr = new int*[m];
- for (int i = 0; i < m; i++) {
- arr[i] = new int[m];
- }
- srand(time(NULL));
- cout << "Generated array: " << endl;
- for (int i = 0; i < m; i++) {
- for (int j = 0; j < m; j++) {
- arr[i][j] = rand() % 10 + 1;
- cout << setw(3) << arr[i][j];
- }
- cout << endl;
- }
- bool s = true;
- for (int i = 0; i < m; i++) {
- for (int j = 0; j < m - i; j++) {
- if (arr[i][j] != arr[m - j - 1][m - i - 1]) {
- s = false;
- break;
- }
- }
- }
- if (!s) {
- cout << "No";
- } else {
- cout << "Yes";
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement