Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n,m;
  7.     cin >> n >> m;
  8.  
  9.     vector<int> frst, scnd;
  10.  
  11.     for (int i=0;i<n;i++) {
  12.         int a;
  13.         cin >> a;
  14.         frst.push_back(a);
  15.     }
  16.  
  17.     for (int i=0;i<m;i++) {
  18.         int a;
  19.         cin >> a;
  20.         scnd.push_back(a);
  21.     }
  22.  
  23.     for (int i=0;i<n;i++) {
  24.         for (int j=0;j<m;j++) {
  25.             if (frst[i] == scnd[j]) {
  26.                 cout << scnd[j] << ' ';
  27.                 break;
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement