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