Advertisement
STANAANDREY

inc->adi

Feb 15th, 2021 (edited)
845
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #define NMAX 103
  4. int n, m;
  5. bool a[NMAX][NMAX];
  6. int inc[NMAX][NMAX];
  7.  
  8. void read() {
  9.     cin >> n >> m;
  10.     for (int i = 1; i <= n; i++) {
  11.         for (int j = 1; j <= m; j++) {
  12.             cin >> inc[i][j];
  13.         }
  14.     }
  15. }
  16.  
  17. void solve() {
  18.     for (int j = 1; j <= m; j++) {
  19.         int x, y;
  20.         for (int i = 1; i <= n; i++) {
  21.             if (inc[i][j] == 1) {
  22.                 x = i;
  23.             }
  24.             if (inc[i][j] == -1) {
  25.                 y = i;
  26.             }
  27.         }
  28.         a[x][y] = true;
  29.     }
  30. }
  31.  
  32. void write() {
  33.     for (int i = 1; i <= n; i++) {
  34.         for (int j = 1; j <= n; j++) {
  35.             cout << a[i][j] << ' ';
  36.         }
  37.         cout << endl;
  38.     }
  39. }
  40.  
  41. int main() {
  42.     read();
  43.     solve();
  44.     write();
  45.     return 0;
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement