Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. ofstream fout("maxim5.out");
  4. ifstream fin("maxim5.in");
  5.  
  6. int x, nr, Max, Max2, nr2 = 100000000;
  7.  
  8. int main()
  9. {
  10.     while(fin >> x) {
  11.         nr++;
  12.         if(!x) {
  13.             if(nr <= nr2) {
  14.                 nr2 = nr; nr = 0;
  15.                 Max2 = max(Max2, Max); Max = 0;
  16.             }
  17.             else { nr = 0; Max = 0; }
  18.         }
  19.         else if(nr <= nr2 && x > Max) Max = x;
  20.     }
  21.     fout << Max2;
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement