Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream f("bac.txt");
- void Read(int& n, int& m, int a[100], int b[100])
- {
- f >> n >> m;
- for(int i = 0; i < n; ++i)
- f >> a[i];
- for(int j = 0; j < m; ++j)
- f >> b[j];
- }
- void Ord(int n, int m, int a[100], int b[100])
- {
- int i1 = 0, i2 = 0, x;
- cout << (x = (a[i1] < b[i2] ? a[i1++] : b[i2++])) << " ";
- while(i1 < n && i2 < m)
- {
- if(a[i1] < b[i2])
- {
- if(x & 1)
- cout << (x = a[i1]) << " ";
- ++i1;
- }
- else
- {
- if(!(x & 1))
- cout << (x = b[i2]) << " ";
- ++i2;
- }
- }
- if((x & 1) && i1 < n)
- cout << a[i1];
- if(!(x & 1) && i2 < m)
- cout << b[i2];
- }
- int main()
- {
- int n, m, a[100], b[100];
- Read(n, m, a, b);
- Ord(n, m, a, b);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement