Advertisement
KedrikFeeD

Simetrical simple

Dec 2nd, 2021
984
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.59 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4.     setlocale(LC_ALL, "Rus");
  5.     int dimension = 2;
  6.     int a[101][101];
  7.     cout << "Введите размерность матрицы:";
  8.     cin >> dimension;
  9.     bool simetrical = true;
  10.     cout << "Введите матрицу:\n";
  11.     for (int i = 0; i < dimension; i++) {
  12.         for (int j = 0; j < dimension; j++) {
  13.             cin >> a[i][j];
  14.         }
  15.         cout << endl;
  16.     }
  17.     cout << endl;
  18.     for (int i = 0; i < dimension; i++) {
  19.         for (int j = 0; j < dimension; j++) {
  20.             cout << a[i][j];
  21.             cout << "\t";
  22.         }
  23.         cout << endl;
  24.     }
  25.     for (int i = 0; i < dimension; i++) {
  26.         for (int j = 0; j < dimension; j++) {
  27.             if (i < j) {
  28.                 if (a[i][j] != a[j][i]) {
  29.                     simetrical = false;
  30.                 }
  31.  
  32.             }
  33.         }
  34.     }
  35.     if (simetrical) {
  36.         cout << "Матрица симметрична!\n";
  37.     }
  38.     else {
  39.         cout << "Матрица не симметрична!\n";
  40.     }
  41.     simetrical = true;
  42.     cout << "Введите матрицу:\n";
  43.     for (int i = 0; i < dimension; i++) {
  44.         for (int j = 0; j < dimension; j++) {
  45.             cin >> a[i][j];
  46.         }
  47.         cout << endl;
  48.     }
  49.     cout << endl;
  50.     for (int i = 0; i < dimension; i++) {
  51.         for (int j = 0; j < dimension; j++) {
  52.             cout << a[i][j];
  53.             cout << "\t";
  54.         }
  55.         cout << endl;
  56.     }
  57.     for (int i = 0; i < dimension; i++) {
  58.         for (int j = 0; j < dimension; j++) {
  59.             if (i + j < dimension + 1) {
  60.                 if (a[i][j] != a[j][i]) {
  61.                     simetrical = false;
  62.                 }
  63.  
  64.             }
  65.         }
  66.     }
  67.  
  68.     if (simetrical) {
  69.         cout << "Матрица симметрична!";
  70.     }
  71.     else {
  72.         cout << "Матрица не симметрична!";
  73.     }
  74.     simetrical = true;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement