Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int n,m,i,j, a[1000],b[1000];
- cin>>n>>m;
- for(i=1; i<=n; i++) cin>>a[i];
- for(i=m; i>=1; i--) cin>>b[i];
- i=1;
- j=1;
- while(i<=n && j<=m)
- {
- if(a[i]<b[j])
- {
- if(a[i]%2==0) cout<<a[i]<<" ";
- i++;
- }
- else
- {
- if(b[j]%2==0) cout<<b[j]<<" ";
- j++;
- }
- }
- while(i<=n)
- {
- if(a[i]%2==0) cout<<a[i]<<" ";
- i++;
- }
- while(j<=m)
- {
- if(b[j]%2==0) cout<<b[j]<<" ";
- j++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement