Advertisement
SelinD

v98s3ex4

May 7th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n,m,i,j, a[1000],b[1000];
  6. cin>>n>>m;
  7. for(i=1; i<=n; i++) cin>>a[i];
  8. for(i=m; i>=1; i--) cin>>b[i];
  9.  
  10. i=1;
  11. j=1;
  12. while(i<=n && j<=m)
  13. {
  14. if(a[i]<b[j])
  15. {
  16. if(a[i]%2==0) cout<<a[i]<<" ";
  17. i++;
  18. }
  19. else
  20. {
  21. if(b[j]%2==0) cout<<b[j]<<" ";
  22. j++;
  23. }
  24. }
  25. while(i<=n)
  26. {
  27. if(a[i]%2==0) cout<<a[i]<<" ";
  28. i++;
  29. }
  30. while(j<=m)
  31. {
  32. if(b[j]%2==0) cout<<b[j]<<" ";
  33. j++;
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement