Advertisement
rotti321

sim BAC 2018 SIII Ex. 4

Mar 28th, 2018
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <fstream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int x,y,a,okx=0,oky=0;
  9.     ifstream fin("bac.txt");
  10.     fin>>x>>y;
  11.     if(x>y)
  12.     {
  13.         a=y;
  14.         y=x;
  15.         x=a;
  16.     }
  17.     while(fin>>a)
  18.     {
  19.         if((x<a)&&(okx==0))
  20.         {
  21.             cout<<x;
  22.             okx=1;
  23.         }
  24.         if((y<a)&&(oky==0))
  25.         {
  26.             cout<<y;
  27.             oky=1;
  28.         }
  29.         cout<<a;
  30.     }
  31.     if(okx==0)
  32.         cout<<x;
  33.     if(oky==0)
  34.         cout<<y;
  35.    
  36.     return 0;
  37.  
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement