Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>#include<iostream>
- #include<fstream>
- using namespace std;
- ifstream fin("bac.in.cpp");
- //ofstream fout("bac.out");
- int main()
- {
- int maxi=0,pozmax,ok=1,n,i,x[100];
- fin>>n;
- for(i=1;i<=n;i++)
- {
- fin>>x[i];
- }
- for(i=1;i<=n;i++)
- {
- if(x[i]>maxi)
- {
- maxi=x[i];
- pozmax=i;
- }
- }
- if(maxi!=0 && maxi!=n)
- {
- for(i=1;i<pozmax;i++)
- {
- if(x[i]>x[i+1])
- {
- ok=0;
- break;
- }
- for(i=pozmax;i<n;i++)
- {
- if(x[i]<x[i+1])
- {
- ok=0;
- break;
- }
- }
- }
- }
- if(ok==1)
- {
- cout<<"corect";
- cout<<endl;
- cout<<maxi;
- }
- else cout<<"incorect";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement