Advertisement
STANAANDREY

reunion

Apr 7th, 2019
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  int a[1000],b[1000],c[2000],n,m,i,k,j,ok;
  7.  cout<<"n=";cin>>n;
  8. for (i=0;i<n;i++)
  9. cin>>a[i];
  10. cout<<"m=";cin>>m;
  11. for (i=0;i<m;i++)
  12. cin>>b[i];
  13. for (i=0;i<n;i++)
  14. c[i]=a[i];
  15. k=n;
  16.  
  17. for (j=0;j<m;j++)
  18. {
  19.  ok=1;
  20.  for (i=0;i<n;i++)
  21.     if (b[j]==a[i])
  22.     ok=0;
  23.     if (ok)
  24.     {
  25.         c[k]=b[j];
  26.         k++;
  27.     }
  28. }
  29. cout<<"A reunit cu B:"<<endl;
  30. for (i=0;i<k;i++)
  31.  cout<<c[i]<<' ';
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement