Varianta 98 / Subiectul 3 / Problema 4 |
#include<fstream.h> ifstream f("date.txt"); void main() { int i,j,k,n,m,a[3000], b[3000], c[6000]; f>>n>>m; for(i=1;i<=n;i++) f>>a[i]; for(i=1;i<=m;i++) f>>b[i]; i=1; j=m; k=1; while(i<=n && j>=1) if(a[i]<b[j]) { if(a[i]%2==0) c[k++]=a[i]; i++; } else { if(b[j]%2==0) c[k++]=b[j]; j--; } while(i<=n) { if(a[i]%2==0) c[k++]=a[i]; i++; } while(j>=1) { if(b[j]%2==0) c[k++]=b[j]; j--; } for(i=1;i<k;i++) cout<<c[i]<<" "; } |