Aleksandr_Grigoryev

11a

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