// (C) 2013-2014, Sergei Zaychenko, KNURE, Kharkiv, Ukraine #ifndef _ARITHMETIC_PROGRESSION_HPP_ #define _ARITHMETIC_PROGRESSION_HPP_ /*****************************************************************************/ #include /*****************************************************************************/ class ArithmeticProgression { public: ArithmeticProgression(); ArithmeticProgression(double _step, double _initialvalue); ArithmeticProgression(double step1); const double getInitialValue() const; const double getStep()const; double getIthElement(int _i); double partialSum(int _i, int _k); double partialAverage(int _i, int _k); bool operator == (const ArithmeticProgression & _ArithmeticProgression) const; bool operator != (const ArithmeticProgression & _ArithmeticProgression) const; void display(int _i, int _k, std::ostream& disp); bool matchesArray(const int* _pElements, int _N); ArithmeticProgression makeInverted(); private: double m_initialvalue; double m_step; int m_i; int m_k; void m_checkRange(int a, int b); }; inline const double ArithmeticProgression::getInitialValue() const { return m_initialvalue; } inline const double ArithmeticProgression::getStep()const { return m_step; } /*****************************************************************************/ #endif // _ARITHMETIC_PROGRESSION_HPP_