title: Combining two dynamically allocated arrays
body: <p>There are two dynamically allocated arrays, and I need to merge them into one. Here is the code, but it is not correct:</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main(){ 
      system(&quot;chcp 1251&gt;null&quot;);
      int n, m;
      cin &gt;&gt; n;
      cin &gt;&gt; m;
      int* a = new int[n];
      int* b = new int[m];
      int* w = new int[n + m];
      int k = 0;
      for (int i = 0; i &lt; n; i++) {
          cin &gt;&gt; a[i];
          w[i] = a[i];
      }
      for (int i = 0; i &lt; m; i++) {
          cin &gt;&gt; b[i];
      }
      for (int i = 0; i &lt; n+m; i++) {
          w[i] = (i &lt; m ? a[i] : b[i - n - 1]);
          cout&lt;&lt;w[i]&lt;&lt;&quot; &quot;;
      }
      delete[] a;
      delete[] b;
      delete[] w;
      system(&quot;pause&gt;null&quot;);
      return 0;
  }
  </code></pre>
  <p>How to fix it to be like this:</p>
  <pre class="lang-none prettyprint-override"><code>A = [1,2,3,4]
  B = [1,2,5,6]
  W [1,2,3,4,5,6]
  </code></pre>
  <p>NO USING SET OR VECTOR</p>