Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
549 B
1
Indexable
Never
class Intervallum
{
private:
	double* v;

public:
	Intervallum(double, double);
	~Intervallum()
	{
		delete[] v;
	}
	void duplaz();
	void kiir();
};

void felCserel(double& a, double& b)
{
	double aux = a;
	a = b;
	b = aux;
}

Intervallum::Intervallum(double a, double b)
{
	v = new double[2];

	if (a > b)
		felCserel(a, b);

	v[0] = a;
	v[1] = b;
}

void Intervallum::duplaz()
{
	double c = (v[0] + v[1]) / 4.0;

	v[0] -= c;
	v[1] += c;
}

void Intervallum::kiir()
{
	std::cout << v[0] << ' ' << v[1];
}