Advertisement
STANAANDREY

diferenta

Apr 7th, 2019
263
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. using namespace std;
  3. // a-b
  4. int main()
  5. {
  6.     int a[1000],b[1000],c[2000],n,m,i,k,j,ok;
  7.     cout<<"n=";
  8.     cin>>n;
  9.     for (i=0; i<n; i++)
  10.         cin>>a[i];
  11.     cout<<"m=";
  12.     cin>>m;
  13.     for (i=0; i<m; i++)
  14.         cin>>b[i];
  15.     k=0;
  16.     for (j=0; j<n; j++) //j<m
  17.     {
  18.         ok=1;
  19.         for (i=0; i<m; i++) //i<n
  20.             if (b[i]==a[j]) //inversezi a cu b
  21.                 ok=0;
  22.         if (ok)
  23.         {
  24.             c[k]=a[j]; //b[j]
  25.             k++;
  26.         }
  27.     }
  28.     cout << "a-b:"<<endl;
  29.     for (i=0; i<k; i++)
  30.         cout<<c[i]<<' ';
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement