Given are two one-dimensional arrays A and B which are sorted in ascending
order. Write a program to merge them into a single sorted array C that
contains every item from arrays A and B in ascending order.
# include
# include
void main()
{
int A[20],B[20],C[40],n,i,j=0,t,k=1;
clrscr();
printf("Enter the number of elements in an array:");
scanf("%d",&n);
for(i=0;i
printf("\nEnter the %d valueof array1:",i+1);
scanf("%d",&A[i]);
}
for(i=0;i
printf("\nEnter the %d value of array2:",i+1);
scanf("%d",&B[i]);
}
for(i=0;i
for(j=0;j
C[i]=B[j];
i++;
}
for(j=0;j {
for(k=j;k {
if(C[j]>C[k])
{
t=C[j];
C[j]=C[k];
C[k]=t;
}
}
// k++;
}
for(j=0;j printf("\n%d",C[j]);
getch();
}
/* Output
Enter the number of elements in an array:2
Enter the 1 valueof array1:6
Enter the 2 valueof array1:5
Enter the 1 value of array2:89
Enter the 2 value of array2:1
1
5
6
89
*/
Shopping In MUMBAI
Are you searching for Discounts, offers, sale in Mumbai ? You are in the right place. MUMBAI, a shopping haven, has no dearth of great discounts and sales. This blog features the best MUMBAI shopping offers, sale, discounts and deals and bargains CURRENTLY GOING on in Mumbai plus a few free things thrown in on top.
Don't wait for it because once they are gone, they are gone. Hurry!..By clicking the "Like" button you will receive a daily update of discounts, sale, offers going on in Mumbai. LIKE IT.... SHARE IT...njoY.
Tuesday, December 30, 2008
Write a program to merge 2 arrays into a single sorted array
Posted by ars at 8:40 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment