title: C++ Union , Intersection , Difference
body: <p>So I'm working on a code to find the Union, Intersection and Difference between two arrays. I'm done with the Union and Intersection but i just can't figure out the difference(A - B) ,For example A={1,3,6,9,7,9} , B={2,3,-2,9} i want to get A - B = { 1,6,7,0} .</p>
  
  <p>I don't want to use any other library except iostream.</p>
  
  <p>This is my code so far.</p>
  
  <pre><code>/* Prints union of A[] and B[]
     SizeA is the number of elements in A[]
     SizeB is the number of elements in B[] */
  
  cout &lt;&lt; "\nUnion of A and B = "; //
  i = 0; j = 0;
  while (i &lt; SizeA &amp;&amp; j &lt; SizeB)
  {
      if (A[i] &lt; B[j])
          cout &lt;&lt; A[i++] &lt;&lt; " ";
  
      else if (B[j] &lt; A[i])
          cout &lt;&lt; B[j++] &lt;&lt; " ";
  
      else
      {
          cout &lt;&lt; B[j++] &lt;&lt; " ";
          i++;
      }
  }
  /* Print remaining elements of the larger array */
  while (i &lt; SizeA)
      cout &lt;&lt; A[i++] &lt;&lt; " ";
  
  while (j &lt; SizeB)
      cout &lt;&lt; B[j++] &lt;&lt; " ";
  
  
  
  cout &lt;&lt; "\nIntersection of A and B = ";
  for (i = 0; i &lt; SizeA; i++) //for loop to calculate the intersection of A and B.
  {
      for (j = 0; j &lt; SizeB; j++)
      {
          if (A[i] == B[j])
          {
              cout &lt;&lt; A[i] &lt;&lt; " ";
          }
      }
  }
  </code></pre>