Advertisement
Ursu

Untitled

Apr 26th, 2020
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <fstream>
  2. #include <climits>
  3. using namespace std;
  4.  
  5. ifstream fin("maxim5.in");
  6. ofstream fout("maxim5.out");
  7.  
  8. int v[2][1000];     // matrice unde v[0][k] = nr elementelor de pe linia k si v[1][k] = maximul de pe linia k
  9.  
  10. int main()
  11. {
  12.         int maxNr=INT_MIN, i, k=0, a, minim=INT_MAX;
  13.         while(fin>>a)
  14.         {
  15.                 if(a!=0)
  16.                 {
  17.                         v[0][k]++;
  18.                         if(v[1][k]<a)
  19.                                 v[1][k]=a;
  20.                 }
  21.                 else
  22.                 {
  23.                         if(v[0][k]<minim)
  24.                                 minim=v[0][k];
  25.                         ++k;
  26.                 }
  27.         }
  28.         for(i=0; i<k; ++i)
  29.         {
  30.                 if(v[0][i]==minim)
  31.                 {
  32.                         if(v[1][i]>maxNr)
  33.                                 maxNr = v[1][i];
  34.                 }
  35.         }
  36.         fout<<maxNr;
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement