csansoon

P6.12 P90620 Pica d'Estats

Nov 7th, 2018
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool peak(int n1, int n2, int n3) {
  5.     if (n1<n2&&n2>n3) return true;
  6.     else return false;
  7. }
  8.  
  9. int main() {
  10.     int n1,n2,n3;
  11.     bool higherPeak=false;
  12.     cin>>n1;
  13.     cin>>n2;
  14.     while(cin>>n3&&n3!=0) {
  15.         if (peak(n1,n2,n3)&&n2>3143) higherPeak=1;
  16.         n1=n2;
  17.         n2=n3;
  18.     }
  19.     if (higherPeak) cout<<"YES"<<endl;
  20.     else cout<<"NO"<<endl;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment