-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLab №3
42 lines (39 loc) · 845 Bytes
/
Lab №3
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
#include <iostream>
#include <math.h>
#include <conio.h>
#include <stdlib.h>
using namespace std;
int main()
{
system("chcp 1251>null");
double a,x,eps,s;
do{
cout << "Х не повинен = 0. Введіть x = ";
cin >> x;
}
while (x == 0);
do{
cout << "А не повинно = 0.Введіть a = ";
cin >> a;
}
while (a == 0);
do{
cout << "Е не повинно <=0.Введіть точність eps = ";
cin >> eps;
}
while (eps <= 0);
int k=1, fk=1;
double stax=1, stx=1, d=sin(a+x);
while (fabs(d) > eps)
{
k++;
fk *= k;
stax *=(pow(a,k)+pow(x,k));
d=sin(stax)/fk;
s+=d;
}
cout << "Sum = " << s << endl;
cout << "k = " << k << endl;
_getch();
return 0;
}