Advertisement
SelinD

ex37/126

Jun 25th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include<iostream>#include<iostream>
  2. #include<fstream>
  3. using namespace std;
  4. ifstream fin("bac.in.cpp");
  5. //ofstream fout("bac.out");
  6. int main()
  7. {
  8. int maxi=0,pozmax,ok=1,n,i,x[100];
  9. fin>>n;
  10. for(i=1;i<=n;i++)
  11. {
  12. fin>>x[i];
  13. }
  14. for(i=1;i<=n;i++)
  15. {
  16. if(x[i]>maxi)
  17. {
  18. maxi=x[i];
  19. pozmax=i;
  20. }
  21. }
  22. if(maxi!=0 && maxi!=n)
  23. {
  24. for(i=1;i<pozmax;i++)
  25. {
  26. if(x[i]>x[i+1])
  27. {
  28. ok=0;
  29. break;
  30. }
  31. for(i=pozmax;i<n;i++)
  32. {
  33. if(x[i]<x[i+1])
  34. {
  35. ok=0;
  36. break;
  37. }
  38. }
  39. }
  40. }
  41. if(ok==1)
  42. {
  43. cout<<"corect";
  44. cout<<endl;
  45. cout<<maxi;
  46. }
  47. else cout<<"incorect";
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement