rengetsu

KVALIF_VGTU_D

Mar 17th, 2020
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n, m;
  6.     cin >> n >> m;
  7.     int qq[n][m];
  8.     for(int i = 0; i < n; i++)
  9.     {
  10.         for(int y = 0; y < m; y++)
  11.         {
  12.             cin >> qq[i][y];
  13.         }
  14.     }
  15.     for(int i = 0; i < n; i++)
  16.     {
  17.         for(int y = 0; y < m; y++)
  18.         {
  19.             if(m == 1 && qq[i][y] == -1 && y == m-1 && i == n-1){cout <<qq[i-1][y]+1;}
  20.             else if(m == 1 && qq[i][y] == -1 && y == 0 && i == 0){cout << qq[i+1][y]-1;}
  21.             else if( qq[i][y] == -1 && y == 0){cout << (qq[i][y+1])-1;}
  22.             else if( qq[i][y] == -1 && y == m-1){cout << (qq[i][y-1])+1;}
  23.             else if( qq[i][y] == -1 ){cout << (qq[i][y-1])+1;}
  24.         }
  25.     }
  26.     return 0;
  27. }
Add Comment
Please, Sign In to add comment