Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- using namespace std;
- int main() {
- ifstream F("in1.txt");
- ifstream G("in2.txt");
- if (!F || !G)
- {
- cout << "can't open file";
- }
- ofstream H("out.txt");
- int x, y;
- F >> x;
- G >> y;
- while (F.peek() != EOF && G.peek() != EOF)
- {
- if (x<y)
- {
- H << x << " ";
- F >> x;
- }
- else
- {
- if (x != y)
- H << y << " ";
- G >> y;
- }
- }
- if (F.peek() == EOF)
- {
- while (G.peek() != EOF && y < x)
- {
- {
- if (x != y)
- H << y << " ";
- G >> y;
- }
- }
- if (y < x)
- {
- if (x != y)
- H << y << " " << x << " ";
- }
- else
- {
- if (x != y)
- H << x << " " << y << " ";
- }
- while (G.peek() != EOF)
- {
- {
- G >> y;
- if (x != y)
- H << y << " ";
- }
- }
- }
- else
- {
- while (F.peek() != EOF && x < y)
- {
- {
- if (x != y)
- H << x << " ";
- F >> x;
- }
- }
- if (y < x)
- {
- H << y << " " << x << " ";
- }
- else
- {
- if (x != y)
- H << x << " " << y << " ";
- }
- while (F.peek() != EOF)
- {
- {
- F >> x;
- if (x != y)
- H << x << " ";
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment