Advertisement
rengetsu

ProcedurProgramavimas_2.16

Apr 5th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n,z[100000],max=1000001;
  6.     cin>>n;
  7.     for(int i=0;i<n;i++)
  8.     {
  9.         cin>>z[i];
  10.     }
  11.     for(int g=0;g<n;g++)
  12.     {
  13.         if(g==0)
  14.         {
  15.             if(z[g]>z[g+1] && z[g]>=0 && z[g]<max)
  16.             {
  17.                 max=z[g];
  18.             }
  19.         }
  20.         else if(g==(n-1))
  21.         {
  22.             if(z[g]>z[g-1] && z[g]>=0 && z[g]<max)
  23.             {
  24.                 max=z[g];
  25.             }
  26.         }
  27.         else
  28.         {
  29.             if(z[g]>z[g-1] && z[g]>z[g+1] && z[g]>=0 && z[g]<max)
  30.             {
  31.                 max=z[g];
  32.             }
  33.         }
  34.     }
  35.     if(max!=1000001){cout<<max<<endl;}else{cout<<"NO"<<endl;}
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement