Advertisement
STANAANDREY

subspara

Mar 25th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  int n,i,a[1000],maxi=0,nr=0,st,st_f,ok=0;
  7.  cout<<"n=";cin>>n;
  8.  for (i=0;i<n;i++)
  9.  cin>>a[i];
  10.  
  11.   for (i=0;i<n;i++)
  12. {
  13.     if (a[i]%2==0) {
  14.        if (!ok) {
  15.        st=i;
  16.        ok=1;
  17.        }
  18.         nr++;
  19.     }
  20.     else
  21.     {
  22.      ok=0;
  23.      nr=0;
  24.     }
  25.     if (maxi<nr)
  26.     {
  27.         st_f=st;
  28.         maxi=nr;
  29.     }
  30. }
  31. cout<<"lungime:"<<maxi<<"\nsecventa: ";
  32. for (i=st_f;i<st_f+maxi;i++)
  33.     cout<<a[i]<<' ';
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement