Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Model BAC 2016 SIII Ex 4
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("date.in");
- int p1=-1,p2=-1,imp1=-1,imp2=-1,x,ok=1;
- int main()
- {
- while(fin>>x){
- if(x%2==0){ ///x par
- if(p1==-1){ ///primul nr par din sir
- p1=x;
- }
- else
- if(p2==-1){ ///stabilesc al 2-lea nr par
- p2=x;
- if(p1<=p2){
- ok=0;
- }
- }
- else{
- p1=p2;
- p2=x;
- if(p1<=p2){
- ok=0;
- }
- }
- }
- else{ /// x impar
- if(imp1==-1){ ///primul nr par din sir
- imp1=x;
- }
- else
- if(imp2==-1){ ///stabilesc al 2-lea nr par
- imp2=x;
- if(imp1>=imp2){
- ok=0;
- }
- }
- else{
- imp1=imp2;
- imp2=x;
- if(imp1>=imp2){
- ok=0;
- }
- }
- }
- }
- if (ok==0){
- cout<<"NU";
- }
- else{
- cout<<"DA";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement