Advertisement
hopingsteam

Untitled

May 11th, 2020
1,160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include    <iostream>
  2. #include    <fstream>
  3.  
  4. using namespace std;
  5.  
  6. ifstream fin("fisier.in");
  7.  
  8. int main()
  9. {
  10.     int nr, nrPrec;
  11.     int ratCrt, ratPrec, ratLungMax;
  12.     int lung = 0, lungMax = 0;
  13.  
  14.     fin >> nrPrec;
  15.     while(fin >> nr)
  16.     {
  17.         ratCrt = nr - nrPrec;
  18.         if(ratPrec == ratCrt)
  19.         {
  20.             lung++;
  21.             if(lung > lungMax)
  22.             {
  23.                 lungMax = lung;
  24.                 ratLungMax = ratCrt;
  25.             }
  26.         }
  27.         else
  28.             lung = 0;
  29.  
  30.         ratPrec = ratCrt;
  31.         nrPrec = nr;
  32.     }
  33.  
  34.     if(lungMax != 0)
  35.         cout << ratLungMax;
  36.     else
  37.         cout << "nu exista";
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement