Advertisement
STANAANDREY

bacT7 SIII 2

May 26th, 2021
1,267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #define NMAX 22
  4. int n, m;
  5. int a[NMAX][NMAX];
  6.  
  7. bool has(int x) {
  8.     for (int i = 1; i <= m; i++) {
  9.         if (a[i][n] == x) {
  10.             return true;
  11.         }
  12.     }
  13.     return false;
  14. }
  15.  
  16. int main() {
  17.     cin >> m >> n;
  18.     for (int i = 1; i <= m; i++) {
  19.         for (int j = 1; j <= n; j++) {
  20.             cin >> a[i][j];
  21.         }
  22.     }
  23.     for (int i = 1; i <= m; i++) {
  24.         if (has(a[i][1])) {
  25.             cout << a[i][1] << ' ';
  26.         }
  27.     }
  28.     return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement