Advertisement
rotti321

Var 23 SIII Ex 4

Apr 11th, 2018
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. /**
  2. http://bacinfo.cnlr.ro/subiecte-bac/2009/e_info_intensiv_c_siii_023.pdf
  3. Var 23 SIII Ex 4
  4. */
  5. #include <iostream>
  6. #include <fstream>
  7. using namespace std;
  8.  
  9. struct interval
  10. {
  11.     int a,b;
  12. }s[1001] ;
  13.  
  14. ifstream f("BAC.TXT");
  15.  
  16. int main()
  17. {
  18.     int n;
  19.     f>>n;
  20.     for(int i=1;i<=n;i++)
  21.     {
  22.         f>>s[i].a>>s[i].b;
  23.     }
  24.  
  25.     int ok=1;
  26.     for(int i=1;i<=n;i++)
  27.     {
  28.         ok=1;
  29.         for(int j=1;j<=n;j++)
  30.         {
  31.             if(i!=j)
  32.             {
  33.                 if(s[i].a<=s[j].a && s[i].b>=s[j].a ||
  34.                    s[i].a<=s[j].b && s[i].b>=s[j].b ||
  35.                    s[i].a>=s[j].a && s[i].b<=s[j].b)
  36.                    ok=0;
  37.             }
  38.         }
  39.         if(ok==1)
  40.             cout<<s[i].a<<" "<<s[i].b<<endl;
  41.     }
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement