Guest User

Untitled

a guest
Apr 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. //Justyna Koczar
  2. #include <iostream>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. int main(){
  7.     long i,j,k,n,m,p;
  8.     long tab1[140001],tab2[140001],tab3[140001];
  9.     bool wpis;
  10.      
  11.     cin>>n;
  12.     for(i=0;i<n;i++){
  13.         cin>>tab1[i];
  14.     }
  15.     cin>>m;
  16.     for(i=0;i<m;i++){
  17.         cin>>tab2[i];
  18.     }
  19.    
  20.     p=0;
  21.     for (i=0;i<n;i++){
  22.         for(j=0;j<m;j++){
  23.             wpis=true;
  24.             if(tab1[i]==tab2[j]){          
  25.                 for (k=0;k<p;k++){
  26.                     if(tab3[k]==tab1[i]){                      
  27.                         wpis=false;
  28.                         break;
  29.                     }
  30.                 }
  31.                 if (wpis){
  32.                     tab3[p]=tab1[i];
  33.                     p++;
  34.                 }
  35.                    
  36.             }
  37.            
  38.         }
  39.     }  
  40.     cout<<p<<endl;
  41.     for (i=0;i<p;i++){
  42.         cout<<tab3[i]<<endl;
  43.     }
  44.     return 0;
  45. }
Add Comment
Please, Sign In to add comment