include stdafx include math include iostream using namespace std doubl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "stdafx.h"
#include "math.h"
#include <iostream>
using namespace std;
double foo (double x, double eps, double a)
{
double func=1.0+a*x;
double mult_x = x;
double up = a;
double q=100.0;
double fact = 1.0;
int i=1;
int m=2;
while( abs(func-q) >= eps)
{ q=func;
fact*=++i;
mult_x*=x;
up*=(a-m+1);
m++;
func+=mult_x*up/fact;
}
return func;
}
void main()
{
double x, eps,a;
cin>>x;
cin>>eps;
cin>>a;
if ((x>-1) && (x<1)) cout<<pow(1+x,a)<<'\t'<<foo(x,eps,a);
else cout<<"otstan Guzhov";
}