#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
double S(double x, double err, double &n)
{
double an = x;
double sum = 0;
for(n = 0; err < fabs(an); n = n + 1)
{
sum += an;
an *= (-1)*x*x*(2*n + 1)/(2*n + 3.0);
}
return sum;
}
int main()
{
double xn, xk, dx, s, n;
cout<<"xn = ";cin>>xn;
cout<<"xk = ";cin>>xk;
cout<<"dx = ";cin>>dx;
cout<<"| x | Sum |atan(x)| n |\n";
for(double x = 0.2; x <= 1.0; x = x + 0.1)
{
s = S(x, 1E-4, n);
cout<<setw(5)<<setprecision(3)<<x<<" | "
<<setw(5)<<setprecision(3)<<s<<" | "
<<setw(5)<<setprecision(3)<<atan(x)<<" | "
<<n<<endl;
}
// system("pause");//Для CodeBlocks добавить в инклуды <cstdlib>
return 0;
}