Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - C language merges two arrays.
C language merges two arrays.
I don't know if the landlord wants a general merge sort or an advanced algorithm merge sort. In the latter case, it is recommended to look at Baidu Encyclopedia/View/90797.htm..

The former.

# include & ltstdio.h & gt

Internationalorganizations (same as international organizations)

Master ()

{

Internationalorganizations (same as international organizations)

a[ 100],b[ 100];

Internationalorganizations (same as international organizations)

anum,bnum,I,j,k,temp

Printf ("Please enter the number of elements of array A:");

scanf("%d ",& ampanum);

for(I = 0; I < Anum; I++)// Array A input

scanf("%d ",& ampa[I]);

Printf ("Please enter the number of elements in array B:");

scanf("%d ",& ampbnum);

for(I = 0; I & ltbnumI++)// array b input

scanf("%d ",& ampb[I]);

k = anum+bnum; //Calculate the total number of data

for(I = 0; I & ltbnumI++)//b array synthesizes array a.

a[anum+I]= b[I];

for(I = 0; I<k-1; i++)

//Select sorting

for(j = I+ 1; j & ltk; j++)

if(a[I]& lt; a[j])

{ temp = a[I];

a[I]= a[j];

a[j]= temp;

}

for(I = 0; I & ltk;; I++)// Output the final array

printf("%8d ",a[I]);

return

0;

}