Advertisement
STANAANDREY

T2_11/04/2019

Apr 11th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n,i,v[1000],l=0,maxi=0,poz;
  7. cout<<"n=";cin>>n;
  8. for (i=0;i<n;i++)
  9. cin>>v[i];
  10. v[n]=-1;
  11. for (i=0;i<=n;i++)
  12. {
  13.     if (v[i]>0)
  14.         l++;
  15.     else
  16.     {
  17.      if (l>maxi)
  18.         {
  19.             maxi=l;
  20.             poz=i-l;
  21.         }
  22.         l=0;
  23.     }
  24. }
  25. for (i=poz;i<poz+maxi;i++)
  26. cout<<v[i]<<' ';
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement