Advertisement
Diamyx

v19s3e4

Apr 19th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. using namespace std;
  4. int main()
  5. {
  6.     ifstream f("v19s3e4NR1.txt");
  7.     ifstream g("v19s3e4NR2.txt");
  8.     int x,y,i=1,j=1,n,m;
  9.     f>>n;
  10.     g>>m;
  11.  
  12.     f>>x;
  13.     g>>y;
  14.  
  15.     while(i<=n && j<=m)
  16.     {
  17.         if(x<y)
  18.         {
  19.             cout<<x<<' ';
  20.             f>>x;
  21.             i++;
  22.         }
  23.         else if(y<x)
  24.         {
  25.             cout<<y<<' ';
  26.             g>>y;
  27.             j++;
  28.         }
  29.         else
  30.         {
  31.             cout<<x<<' ';
  32.             f>>x;
  33.             g>>y;
  34.             i++;
  35.             j++;
  36.         }
  37.     }
  38.     while(i<=n)
  39.     {
  40.         cout<<x<<' ';
  41.         f>>x;
  42.         i++;
  43.     }
  44.     while(j<=m)
  45.     {
  46.         cout<<y<<' ';
  47.         g>>y;
  48.         j++;
  49.     }
  50.     f.close();
  51.     g.close();
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement