SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<set>
  3. #include<list>
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9.     short a,b;
  10.     cin >> a >> b;
  11.     int* p1 = new int[a];
  12.     int* p2 = new int[b];
  13.     for (int i = 0; i < a; i++)
  14.     {
  15.         cin >> p1[i];
  16.     }
  17.     for (int i = 0; i < b; i++)
  18.     {
  19.         cin >> p2[i];
  20.     }
  21.  
  22.     set<int> out;
  23.     for(int i = 0; i < a; i++)
  24.         for (int j = 0; j < b; j++)
  25.         {
  26.             if (p1[i] == p2[j])
  27.             {
  28.                 out.insert(p1[i]);
  29.             }
  30.         }
  31.     for (auto i:out)
  32.     {
  33.         cout << i << " ";
  34.     }
  35.    
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top