//Merging a Array Before another Array
#include<iostream.h>
#include<conio.h>
main()
{
int a[50],b[50];
int m,n,i;
cout<<"Enter size of array A & B";
cin>>m>>n;
cout<<"Enter Elements of A";
for(i=0;i<m;i++)
cin>>a[i];
cout<<"Enter elements of B";
for(i=0;i<n;i++)
cin>>b[i];
for(i=m+n;i>=n;i--)
a[i]=a[i-n];
for(i=0;i<n;i++)
a[i]=b[i];
for(i=0;i<m+n;i++)
cout<<a[i]<<" ";
getch();
}
#include<iostream.h>
#include<conio.h>
main()
{
int a[50],b[50];
int m,n,i;
cout<<"Enter size of array A & B";
cin>>m>>n;
cout<<"Enter Elements of A";
for(i=0;i<m;i++)
cin>>a[i];
cout<<"Enter elements of B";
for(i=0;i<n;i++)
cin>>b[i];
for(i=m+n;i>=n;i--)
a[i]=a[i-n];
for(i=0;i<n;i++)
a[i]=b[i];
for(i=0;i<m+n;i++)
cout<<a[i]<<" ";
getch();
}
No comments:
Post a Comment