#include<conio.h>
#include<iostream.h>
#include<math.h>

#define n 10
#define x0 1.1
#define xnoe 5.0
#define func exp (cos(q))

//----------------------------
long double function (long double q)
{
  return func;
}

//----------------------------
long double stepen (long double x, int q)

{
long double value = 1.0, w = x * x;

for (int i = 0; i < q / 2; i++)

	value *= w;

if (q % 2 == 1) value *= x;

return value;
}

//----------------------------
long double Langr (long double *x, int pos, int h, int num)

{
long double curv = 0;
int i;

if (h == 1)

	{
	for (i = pos; i < n + 1; i++)

		if (i != num)
		curv += x[i];
	}

for (i = pos; i < n + 1 ; i++)

	if (i != num)
	curv += x[i] * Langr (x, i + 1, h - 1, num);


return curv;
}


long double main_tema (long double *x, int h, int num)

{
if (h == 0) return 0;

return Langr (x, 0, h, num);
}

//----------------------------
long double Chisl (long double *dx, int h, long double q, int num)

{
if (h == 0) return q;

if (h == n + 1)
	if (q != 0)
	return (stepen (-1.0, n + 1) * main_tema (dx, h, num) + stepen (-1.0, n) * Chisl (dx, h - 1, q, num)) / q;
	else
	return stepen (-1.0, n) * main_tema (dx, h - 1, num);

return (q * (main_tema (dx, h, num) - Chisl (dx, h - 1, q, num)));
}

//----------------------------
long double interpol (long double q)

{
long double shag, *x, *dx, value = 0.0, a;

shag = (xnoe - x0) / n;

x = new long double [n + 1];
x[0] = x0;

for (int i = 1; i < n + 1; i++)
	x[i] = x[i-1] + shag;

for (i = 0; i < n + 1; i++)
	{
	a = function (x[i]) * Chisl(x, n + 1, q, i) / Chisl (x, n + 1, x[i], i);
	value += a;
	}

return value;
}

/****************************/
void main ()

{
long double shag = (xnoe - x0) / n;

clrscr ();
   	cout << "-Point-----Real Function-----Int Function---" << endl;
for (long double i = x0; i <xnoe + shag; i += shag)
//	cout << i << "    -    " << function (i) << "   -     " << interpol (i) << endl;
//cout << endl;
for (i =shag / 2; i < xnoe /*+ shag / 2*/; i += shag)
	cout << i << "    -    " << function (i) << "   -     " << interpol (i) << endl;
getch ();
}