Advertisement
Guest User

Untitled

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