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