include QtCore QCoreApplication include stdio include iostream include

 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
41
42
43
44
#include <QtCore/QCoreApplication>
#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;
float funct(float x, float n);
float calc(int x, float eps);
int main()
{
float x=0;
float eps=0;
float rez=0;
cout<<"\nЗадайте x\t\n==============\n";
cin>>x;
cout<<"\nЗадайте eps\t\n==============\n";
cin>>eps;
rez=x+calc(x,eps);
cout<<"Результат равен "<<rez;
}
float calc(int x, float eps){
float sum=1;
float buf=1,buf2=1;
int flag=1;
float i=1;
while(flag){
buf=funct(x,i);
if (buf==INFINITY){flag=0; cout<<"\nБЕСКОНЕЧНОСТЬ НЕ ПРЕДЕЛ!";}
if(fabs(buf-buf2)<eps) flag=0;
sum+=buf;
i=i+1;
buf2=buf;
cout<<"\n=========\n"<<i<<"\n=========\n";
}
return sum;
}
float funct(float x, float i){
float z=(2*i+1);
float buf=pow(x,z)/z;
cout<<"Я сработал "<<x<<" "<<i<<" "<<buf<<" "<<z<<" "<<pow(x,z);
return buf;
}