Interclasare

-2 vectori ordonati descrescator => un vector ordonat crescactor-
#include <iostream>
using namespace std;
int main()
 {
 int x[20],y[40],z[60],i,j,m,n,k=0;
 cin>>n>>m;
 for(i=1;i<=n;++i) cin>>x[i];
 for(i=1;i<=m;++i) cin>>y[i];
 i=n;j=m;k=0;
 while(i>=1&&j>=1)
 { if(x[i]<y[j]) z[++k]=x[i–-];
   else z[++k]=y[j–-];
 }
 while(i>=1) z[++k]=x[i–-];
 while(j>=1) z[++k]=y[j–-];
 for(i=k;i>1;++i) cout<<z[i]<<",";
 cout<<z[1];
 return 0;
 }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s