Aleksandr_Grigoryev

HW 13.12.2017 50b

Dec 13th, 2017
93
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. using namespace std;
  3. void create(int **arr, int n,int m)
  4. {
  5.     for (int i = 0; i < n; i++)
  6.     {
  7.         for (int j = 0; j < m; j++)
  8.         {
  9.  
  10.  
  11.             cout << "ENTER arr["<<i<<"]"<<"["<<j<<"]" <<" ";
  12.             cin >> arr[i][j];
  13.         }
  14.     }
  15. }
  16. void show(int **arr, int n, int m)
  17. {
  18.     for (int i = 0; i < n; i++)
  19.     {
  20.         for (int j = 0; j < m; j++)
  21.         {
  22.             cout << arr[i][j] << '\t';
  23.         }
  24.         cout << '\n';
  25.     }
  26. }
  27.  
  28. int main()
  29. {  
  30.     int  n,m;
  31.     cout << "enter n,m";
  32.     cin >> n>>m;
  33.     if (n == m)
  34.     {
  35.         int **a = new int *[n];
  36.         for (int i = 0; i < n; i++)
  37.             a[i] = new int[n];
  38.         create(a, n, m);
  39.         show(a, n, m);
  40.         int x = 0, y = 0, z = 0;
  41.         for (int i = 0; i < n; i++)
  42.        
  43.             for (int j = 0; j <m; j++)
  44.             {
  45.                 if (a[i][j] == 0)
  46.                     y++;
  47.                 if (a[n - i - 1][n - j - 1] == 0)
  48.                     z++;
  49.                 x++;
  50.             }
  51.  
  52.         if ((y == x) || (z == x))
  53.                     cout << "YES";
  54.                 else cout<<"NO";
  55.            
  56.        
  57.        
  58.     }
  59.     else
  60.     cout << "CAN'T";
  61.     system("pause");
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment