Advertisement
rotti321

Model BAC 2016 SIII Ex 4

Mar 9th, 2018
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. ///Model BAC 2016 SIII Ex 4
  2. #include <iostream>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6. ifstream fin("date.in");
  7. int p1=-1,p2=-1,imp1=-1,imp2=-1,x,ok=1;
  8.  
  9. int main()
  10. {
  11.     while(fin>>x){
  12.         if(x%2==0){ ///x par
  13.             if(p1==-1){ ///primul nr par din sir
  14.                 p1=x;
  15.             }
  16.             else
  17.             if(p2==-1){ ///stabilesc al 2-lea nr par
  18.                 p2=x;
  19.                 if(p1<=p2){
  20.                     ok=0;
  21.                 }
  22.             }
  23.             else{
  24.                 p1=p2;
  25.                 p2=x;
  26.                 if(p1<=p2){
  27.                     ok=0;
  28.                 }
  29.             }
  30.         }
  31.         else{ /// x impar
  32.             if(imp1==-1){ ///primul nr par din sir
  33.                 imp1=x;
  34.             }
  35.             else
  36.             if(imp2==-1){ ///stabilesc al 2-lea nr par
  37.                 imp2=x;
  38.                 if(imp1>=imp2){
  39.                     ok=0;
  40.                 }
  41.             }
  42.             else{
  43.                 imp1=imp2;
  44.                 imp2=x;
  45.                 if(imp1>=imp2){
  46.                     ok=0;
  47.                 }
  48.             }
  49.         }
  50.  
  51.     }
  52.     if (ok==0){
  53.         cout<<"NU";
  54.     }
  55.     else{
  56.         cout<<"DA";
  57.     }
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement