#include "iostream" #include "cstdio" using namespace std; int main() { int m,n; int i,j=0,k,top=0; cin>>m; int *a = new int [m]; for(i=0;i<m;i++) cin>>a[i]; cin>>n; int *b = new int [n]; for(i=0;i<n;i++) cin>>b[i]; int *c = new int [m+n]; i=0;j=0; while(i<m&&j<n) { if(a[i]>b[j]) { c[top++] = b[j]; j++; } else if(a[i]<b[j]) { c[top++] = a[i]; i++; } else{ c[top++]=a[i]; c[top++]=b[j]; i++; j++; } } if(i<m) { for(k=i;k<m;k++) c[top++]=a[k]; } else if(j<n) { for(k=j;k<n;k++) c[top++]=b[k]; } for(i=0;i<m+n;i++) printf("%d ",c[i]); delete(a);delete(b);delete(c); }
0.0分
0 人评分