Advertisement
CristinaGeorgiu

Untitled

Mar 5th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int v[1001];
  4. int main()
  5. {
  6. int n,i,lcrt=0,lmax=0,start;
  7. cin>>n;
  8. for(i=1; i<=n; i++)
  9. {
  10. cin>>v[i];
  11. }
  12. for(i=1; i<=n; i++)
  13. {
  14. if(v[i]==0)
  15. {
  16. lcrt++;
  17. if(lmax<lcrt)
  18. {
  19. lmax=lcrt;
  20. start=i-lcrt;
  21. }
  22.  
  23. lcrt=0;
  24. }
  25. }
  26.  
  27. for(i=1; i<=n; i++)
  28. {
  29. if(lcrt>lmax)
  30. {
  31. lmax=lcrt;
  32. start=i-lcrt;
  33. }
  34. }
  35. for(i=start; i<=start+lmax-1; i++)
  36. {
  37. cout<<v[i]<<" ";
  38. }
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement