denis_andrei10

olimpfis

Dec 12th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. using namespace std;
  4. ifstream fin("cuburi.in");
  5. ofstream fout("cuburi.out");
  6. int main()
  7. {
  8.     int cub, i, n, x;
  9.     fin>>n;
  10.     for(i=1; i<=n; i++)
  11.     {
  12.          fin>>x;
  13.     }
  14.     fin>>cub;
  15.     fin.close();
  16.     fin.open("cuburi.in", ios::in);
  17.     fin>>n;
  18.     for(i=1; i<=n; i++)
  19.     {
  20.         fin>>x;
  21.         while(cub>x)
  22.         {
  23.             fout<<x<<' ';
  24.             fin>>x;
  25.             i++;
  26.         }
  27.         fout<<cub<<' ';
  28.         while(i<=n)
  29.         {
  30.             fout<<x<<' ';
  31.             i++;
  32.             fin>>x;
  33.         }
  34.     }
  35.     fin.close();
  36.     fout.close();
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment