Advertisement
Ursu

Untitled

Apr 26th, 2020
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cassert>
  4. using namespace std;
  5.  
  6. ifstream fin("maxim5.in");
  7. ofstream fout("maxim5.out");
  8.  
  9.  
  10. int main(){
  11.     int MaxG = 0, Max, C, cc , n , nrl = 0;
  12.     int gata = 0;
  13.     while(!gata){
  14.         nrl ++;
  15.         if(fin>>n){
  16.             cc = 1, Max = n;
  17.             fin >> n;
  18.             while(n!=0){
  19.                 if(n>Max)
  20.                     Max = n;
  21.                 cc ++;
  22.                 fin >> n;
  23.             }
  24.             if(nrl == 1){
  25.                 C = cc; MaxG = Max;
  26.             }
  27.             else
  28.                 if(cc < C){
  29.                     C = cc; MaxG = Max;
  30.                 }
  31.                 else
  32.                     if(cc == C)
  33.                         if(Max > MaxG)
  34.                             MaxG = Max;
  35.         }
  36.         else
  37.             gata = 1;
  38.     }
  39.     fout << MaxG;
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement