Untitled

 avatar
unknown
c_cpp
3 years ago
639 B
3
Indexable
#ifndef modul_h
#define modul_h

#include <iostream>
using namespace std;

namespace Intervallum
{
	double* v;

	void init(double, double);
	void felsz();
	void duplaz();
	void kiir();
};

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

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

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

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

void Intervallum::felsz()
{
	delete[] v;
}

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

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

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

#endif
Editor is loading...