Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>;
- using namespace std;
- void main()
- {
- short i, maxInd=0, occurences=1, maxEnd=-1;
- int n, *arr;
- FILE *f;
- f=fopen("in.txt","r");
- fscanf(f,"%d",&n);
- cout«"n="«n«endl;
- arr= new int[n];
- for(i=0; i<n; ++i)
- {
- fscanf(f,"%d",&arr[i]);
- cout«arr[i]«" ";
- if(arr[i]>arr[maxInd])
- maxInd=i;
- }
- fclose(f);
- cout«endl;
- for(i=0; i<n; ++i)
- if(arr[i]==arr[maxInd]&&i!=maxInd)
- {
- ++occurences;
- maxEnd=i;
- }
- if(occurences<3)
- cout«"0";
- else
- cout«maxEnd-maxInd-1;
- cout«endl;
- delete []arr;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement