Advertisement
SelinD

ex33pg158

Jun 21st, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int ord(int v[100],int n)
  5. {
  6. int okc=1,okd=1,i,j;
  7. for(i=1; i<n; i++)
  8. {
  9. if(v[i]<v[i+1])
  10. {
  11. okd=0;
  12. }
  13. if(v[i]>v[i+1])
  14. {
  15. okc=0;
  16. }
  17. }
  18.  
  19. if(okc) return 1;
  20. if(okd) return 2;
  21. return 0;
  22. }
  23.  
  24. int main()
  25. {
  26. int p,i,v[100],l=0,lmax=0;
  27. cin>>p;
  28. for(i=1; i<=p; i++) cin>>v[i];
  29. for(i=1; i<=p; i++)
  30. {
  31. if(ord(v,i)==0)
  32. {
  33. lmax=i-1;
  34. break;
  35. }
  36. }
  37. cout<<lmax;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement