Here is working Code
//code is very simple from understanding points of view
//we can solved the problem dynamically or more efficiently but i
posted the solution by taking every things statically ..but its
working what question asked.for
#include<stdio.h>
#include<conio.h>
int main()
{
int a[5]={1,2,3,4,5};
int b[10]={6,7,8,9,10};
int i=0,j=0,x=5,y=5;;
int t=5; //temp which pints to location in array b after 5 elements
while((i<x) && (j<y))
{
if(a[i]<=b[j])
{
b[t]=b[j];
b[j]=a[i];
i++;
j++;
}
else
{
b[t]=a[i];
printf("%d ",b[t]);
b[i]=b[j];
j++;
i++;
}
t++;
}
for(i=0;i<10;i++)
{
printf("%d\t",b[i]);
}
getch();
return 0;
}
Thanks & Regards
Shashank ""The best way to escape from a problem is to solve it."
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.