Advertisement
allia

проверка на симметричность доделать

Sep 15th, 2020
1,559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. void matrix( int n, int m)
  6. {
  7.   int n1=0, n2=0, res1=0;
  8.   int arr[n][m];
  9.  
  10.   for (int i=0; i<n; i++)
  11.    for (int j=0; j<m; j++)
  12.    cin >> arr[i][j];
  13.    if (n%2!=0)
  14.    res1 = n*m;
  15.  
  16.    for (int i=0; i<=n/2; i++)
  17.    for (int j=0; j<m; j++)
  18.     if (arr[i][j]==arr[n-i-1][j])
  19.      n1++;
  20.     //cout << n1 << " ";
  21.     if (n1==res1)
  22.     n1=-1;
  23.  
  24.     else for (int i=0; i<n; i++)
  25.     for (int j=0; j<=m/2; j++)
  26.      if (arr[i][j]==arr[i][m-j-1])
  27.        n2++;
  28.     //cout << n2 << endl;
  29.     if (n1==res1)
  30.     n2=-1;
  31.    
  32.  
  33.     if ( n2==-1 || n1==-1)
  34.     cout << "Yes";
  35.     else cout << "No";
  36.  
  37. }
  38. int main()
  39. {
  40.   int a=0, b=0;
  41.   cin >> a >> b;
  42.   matrix (a, b);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement