arithmetic_progression.hpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// (C) 2013-2014, Sergei Zaychenko, KNURE, Kharkiv, Ukraine
#ifndef _ARITHMETIC_PROGRESSION_HPP_
#define _ARITHMETIC_PROGRESSION_HPP_
/*****************************************************************************/
#include <iostream>
/*****************************************************************************/
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_