fork download
  1.  
  2. #include <iostream>
  3. #include <fstream>
  4. using namespace std;
  5. ifstream f("numere.in");
  6.  
  7. int main()
  8. {
  9. int x, y, lmax=1, l=1, amax, a, rmax, r,n;
  10. bool ok=false;
  11. cin>>n;
  12. cin>>x;
  13. while (cin>>y && n!=0)
  14. {
  15. if (ok=false)
  16. {
  17. ok=true;
  18. l=1; a=x;
  19. r=y-x;
  20. }
  21. else
  22. { if (y-x==r) l++;
  23. else
  24. {
  25. ok=false;
  26. if (l>lmax) lmax=l; amax=a; rmax=r;
  27. }
  28. }
  29. x=y;
  30. }
  31. while (lmax)
  32. {
  33. cout<<amax<<" ";
  34. amax=amax+r;
  35. lmax--;
  36. }
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0.03s 25996KB
stdin
Standard input is empty
stdout
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("numere.in");

int main()
{
    int x, y, lmax=1, l=1, amax, a, rmax, r,n;
    bool ok=false;
    cin>>n;
    cin>>x;
    while (cin>>y && n!=0)
    {
        if (ok=false)
        {
            ok=true;
            l=1; a=x;
            r=y-x;
        }
        else
        { if (y-x==r) l++;
            else 
            {
                ok=false;
                if (l>lmax) lmax=l; amax=a; rmax=r;
            }
        }
        x=y;
    }
    while (lmax)
    {
        cout<<amax<<" ";
        amax=amax+r;
        lmax--;
    }

    return 0;
}