Title Description
Known quantity Group A has m-ascending elements in array B with n descending elements, programmed to deposit all elements A and B into array C in descending order.
Input
The input has two lines, the first line is a positive integer m, then a M integer, the second line is first a positive integer n, then n integers, m, n is less than or equal to 1000000.
Output
Outputs the merged m+n integers, separated by a space between the data. The output takes up one row.
Sample input4 1 3 5 7 3 6 4 2Sample output7 6 5 4 3 2 1Tips
Try to sort out the children to be careful ~~~~~~
1# include <stdio.h>2# define N10000103 intA[n], B[n], c[2*N];4 intMain ()5 {6 intI, J, K, M, n, flag =0;7scanf"%d", &m);8 for(i = m-1; I >=0; i--)9scanf"%d", &a[i]);Ten Onescanf"%d", &n); A for(j =0; J < N; J + +) -scanf"%d", &b[j]); -i =0; thej =0; -K =0; - while(I < m && J <N) - { + if(A[i] >B[j]) -c[k++] = a[i++]; + Else Ac[k++] = b[j++]; at } - while(I <m) -c[k++] = a[i++]; - while(J <N) -c[k++] = b[j++]; - for(i =0; I < K; i++) in { - if(Flag = =0) toprintf"%d", C[i]); + Else -printf"%d", C[i]); theFlag =1; * } $printf"\ n");Panax Notoginseng return 0; -}
Merging of two ordered series