Two arrays that have been small to large are merged into an array of small to large sorts
1#include <stdio.h>2 intMain ()3 {4 intm,n,i,j,k,tem=0;5printf"How many of these two arrays are: \ n");6scanf"%d%d",&m,&n);7 inta[m],b[n],c[m+n];8printf"from small to large enter%d number: \ n", m);9 for(i=0; i<m;i++)Tenscanf"%d",&a[i]); Oneprintf"from small to large enter%d number: \ n", n); A for(i=0; i<n;i++) -scanf"%d",&b[i]); -I=0; j=0; k=0; the Do - { - if(a[i]==B[j]) - { +c[k]=A[i]; -k++; +c[k]=B[j]; Ak++;i++;j++; at } - Else if(a[i]>B[j]) - { -c[k]=B[j]; -j++;k++; - } in Else - { toc[k]=A[i]; +i++; -k++; the } * } $ while((i!=m) && (j!=n));Panax Notoginseng if(i==m) - for(; j<n;j++,k++) thec[k]=B[j]; + if(j==N) A for(; i<m;i++,k++) thec[k]=A[i]; +printf"The result is: \ n"); - for(; tem<m+n;tem++) $printf"%d", C[tem]); $printf"\ n"); - return 0; - } the Test run: -[Email protected]:~/Desktop $./2Wuyi the number of these two arrays: the 6 4 - Enter 6 numbers from small to large: Wu 6 9 One - - - - Enter 4 numbers from small to large: About 1 - - + $ The result is: - 1 6 9 One - - - - - + -[Email protected]:~/Desktop $
"C Practice" two arrays that have been small to large are merged into an array of small to large sorts