#include "stdafx.h"
#include <iostream> 
#include <cmath> 
#include <iomanip> 
#include <stdlib.h> 
#include <iomanip> 
#define _USE_MATH_DEFINES 
#include <conio.h> 
#define PI 3.14159265 
using std::ios;
using namespace std;


int main()
{
	setlocale(0, "");
	double e, Ch = 1, F, n = 0, a, x, dX, Xn, Xk, sim = 0;

	cout << "Введите значения Хн Хк" << endl;
	cin >> Xn;
	cin >> Xk;
	cout << "Введите Е и и шаг" << endl;
	cin >> e;
	cin >> dX;

	cout << setw(5) << setprecision(3) << "№X" << "|" << setw(9) << setprecision(3) << "Результат" << "|" << setw(8) << setprecision(3) << "Контроль" << "|" << endl;

	for (x = Xn; x < Xk; x += dX)
	{
		n = 0;

		F = PI / 2.0;
		Ch = x;

		while (fabs(Ch) > e)
		{
			F += Ch;
			Ch *= (2 * n - 1)*pow(x, 2 * n + 1) / (2 * n*(2 * n + 1));
			n += 1;
			sim++;
		}
		a = asin(x);
		//cout<<" Значение х= "<< x <<" Значение F= "<< F << endl ; 
		cout << setw(5) << setprecision(3) << x << "|" << setw(9) << setprecision(3) << F << "|" << setw(8) << setprecision(3) << a << "|" << sim << endl;
		//cout << "Контрольное значение Ф = " << a << endl; 
	}
	system("pause");
	return 0;
}