Aleksandr_Grigoryev

11v1

Apr 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1.  
  2. #include <fstream>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     ifstream F("input1.txt");
  9.     ifstream G("input2.txt");
  10.     ofstream H("out.txt");
  11.     if (!F || !G)
  12.     {
  13.         cout << "can't open file";
  14.     }
  15.  
  16.     int num1, num2;
  17.     F >> num1;
  18.     G >> num2;
  19.     while (F.peek() != EOF && G.peek() != EOF)
  20.     {
  21.         if (num1 == num2)
  22.         {
  23.             F >> num1;
  24.             G >> num2;
  25.         }
  26.         if (num1<num2)
  27.         {
  28.             H << num1 << " ";
  29.             F >> num1;
  30.         }
  31.         else
  32.             if (num1 != num2)
  33.             {
  34.                 H << num2 << " ";
  35.                 G >> num2;
  36.             }
  37.  
  38.     }
  39.     if (F.peek() == EOF)
  40.     {
  41.         while (G.peek() != EOF && num2 < num1)
  42.         {
  43.             {
  44.                 if (num1 != num2)
  45.                     H << num2 << " ";
  46.                 G >> num2;
  47.             }
  48.         }
  49.         if (num2 < num1)
  50.             if (num1 != num2)
  51.                 H << num2 << " " << num1 << " ";
  52.  
  53.             else
  54.                 if (num1 != num2)
  55.                     H << num1 << " " << num2 << " ";
  56.  
  57.         while (G.peek() != EOF)
  58.         {
  59.             G >> num2;
  60.             if (num1 != num2)
  61.                 H << num2 << " ";
  62.         }
  63.     }
  64.     else
  65.     {
  66.         while (F.peek() != EOF && num1 < num2)
  67.         {
  68.             if (num1 != num2)
  69.                 H << num1 << " ";
  70.             F >> num1;
  71.         }
  72.         if (num2 < num1)
  73.             H << num2 << " " << num1 << " ";
  74.  
  75.         else
  76.             if (num1 != num2)
  77.                 H << num1 << " " << num2 << " ";
  78.  
  79.         while (F.peek() != EOF)
  80.         {
  81.             F >> num1;
  82.             if (num1 != num2)
  83.                 H << num1 << " ";
  84.         }
  85.     }
  86.     return 0;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment