title: Delete last printed element from console
body: <p><strong>QUESTION</strong>   Given two unsorted arrays A of size N and B of size M of distinct elements, the task is to find all pairs from both arrays whose sum is equal to X.</p>
  <pre><code> **INPUT**
      1
      5 5 9
      1 2 4 5 7
      5 6 3 4 8
  
  
  **EXPECTED OUTPUT** 1 8, 4 5, 5 4
  
  **MY OUTPUT**   1 8, 4 5, 5 4,
  </code></pre>
  <p><strong>MY CODE</strong></p>
  <pre><code>#include&lt;bits/stdc++.h&gt;
  using namespace std;
  void Pair(int *a, int*b, int n, int m, int sum) {
      map&lt;int, int&gt;mp;
      for (int i = 0; i &lt; n; i++) {
          int x = a[i];
          for (int i = 0; i &lt; m; i++) {
              if ((sum - x) == b[i])
                  mp[x] = b[i];
          }
      }
  
      for (auto x : mp) {
          cout &lt;&lt; x.first &lt;&lt; &quot; &quot; &lt;&lt; x.second &lt;&lt; &quot;,&quot;;
           
      }
    
  }
  int main() {
  
      int  test ;
      cin &gt;&gt; test;
      for (int i = 0; i &lt; test; i++) {
          int  a[1000000];
          int  b[1000000];
          int  n, m, sum;
          cin &gt;&gt; n &gt;&gt; m &gt;&gt; sum;
          for (int i = 0; i &lt; n; i++) {
              cin &gt;&gt; a[i];
          }
          for (int i = 0; i &lt; m; i++) {
              cin &gt;&gt; b[i];
          }
          Pair(a, b, n, m, sum); 
         
          cout &lt;&lt; endl;
      }
      return 0;
  }
  </code></pre>
  <p>I have already tried /b/b but it does not works here I don't know why please help me print the correct output and also suggest me a better way of doing it</p>
  <p>I have to remove the last comma printed.</p>