The two descending arrays must be shuffled to make them increase progressively, and the number of arrays A is smaller than that of arrays B. Use O (n.
Void processorderedarray (int * arr1, size_t count1, int * arr2, size_t count2) <br/>{< br/> assert (arr1! = NULL & arr2! = NULL); </P> <p> int * Parr = new int [count1 + count2]; <br/> size_t I = 0, j = 0, k = count1 + count2-1; <br/> while (I <count1 & J <count2) <br/>{< br/> If (arr1 [I]> arr2 [J]) <br/>{< br/> Parr [k --] = arr1 [I]; <br/> I ++; <br/>}< br/> else if (arr1 [I] <arr2 [J]) <br/>{< br/> Parr [k --] = arr2 [J]; <br/> J ++; <br/>}< br/> else <br/> {<br/> Parr [k --] = arr1 [I]; <br/> Parr [k --] = arr2 [J]; <br/> I ++; j ++; <br/>}</P> <p> while (I <count1) Parr [k --] = arr1 [I ++]; <br/> while (j <count2) Parr [k --] = arr2 [J ++]; </P> <p> memcpy (arr1, Parr, count1 * sizeof (INT); <br/> memcpy (arr2, Parr + count1, count2 * sizeof (INT); </P> <p> Delete [] Parr; <br/>}</P> <p> int main (INT argc, char * argv []) <br/> {<br/> int A [m] = {6, 5, 2, 1, 0}; <br/> int B [N] = {8, 7, 4, 3 }; <br/> processorderedarray (a, m, B, n); <br/> for (INT I = 0; I <m; I ++) <br/> cout <A [I] <Endl; <br/> for (Int J = 0; j <n; j ++) <br/> cout <B [J] <Endl; <br/> return 0; <br/>}< br/>