Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("fisier.in");
- int main()
- {
- int nr, nrPrec;
- int ratCrt, ratPrec, ratLungMax;
- int lung = 0, lungMax = 0;
- fin >> nrPrec;
- while(fin >> nr)
- {
- ratCrt = nr - nrPrec;
- if(ratPrec == ratCrt)
- {
- lung++;
- if(lung > lungMax)
- {
- lungMax = lung;
- ratLungMax = ratCrt;
- }
- }
- else
- lung = 0;
- ratPrec = ratCrt;
- nrPrec = nr;
- }
- if(lungMax != 0)
- cout << ratLungMax;
- else
- cout << "nu exista";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement