Advertisement
rotti321

T10 SIII ex 2

May 17th, 2021
753
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int m, n, a[21][21] = {}, vf[20] = {}, ok = 0;
  7.     cin >> m >> n;
  8.    
  9.     for(int i = 1; i <= m; i++) {      ///m linii
  10.         for(int j = 1; j <= n; j++) {  ///n coloane
  11.             cin >> a[i][j];
  12.             if(i == 1 && j <= n - 1) vf[a[i][j]]++; ///cresc frecv elem de pe prima linie
  13.             if(j == n && i != 1) {    ///verific ultima coloana
  14.                 vf[a[i][j]]++;
  15.                 if(vf[a[i][j]] == 2) cout << a[i][j] << ' ', ok = 1;
  16.             }
  17.         }
  18.     }
  19.    
  20.     if(ok == 0) cout << "nu exista";
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement