Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int n, x, v[69];
- void citire()
- {
- ifstream f("input.txt");
- while (f >> x)
- {
- n++;
- v[n] = x;
- }
- f.close();
- }
- void determinare()
- {
- int i, maxim = 0, lungime = 0, pozinceput;
- for (i = 1; i < n; i++)
- {
- if (v[i] % 2 == 0)
- lungime++;
- else
- lungime = 0;
- if (lungime > maxim)
- {
- maxim = lungime;
- pozinceput = i - lungime;
- }
- }
- for (i = 1; i <= maxim; i++)
- cout << v[i + pozinceput] << " ";
- cout << "\nSubsirul de lungime maxima cu numere pare consecutive este de lungime " << maxim << " incepand pe pozitia " << pozinceput + 1 << endl;
- }
- int main()
- {
- citire();
- determinare();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement