Jupiter
Каратель
6568 / 3989 / 227
Регистрация: 26.03.2010
Сообщений: 9,273
|
22.07.2011, 21:53
|
|
C++ | 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
| #include <cmath>
#include <iomanip>
#include <iostream>
int main()
{
std::cout << "Enter X: ";
double x;
std::cin >> x;
if (abs(x) < 1.0)
{
std::cout << "Enter N: ";
int N;
std::cin >> N;
if (N > 0)
{
double part = x, total_sum = x;
for (int i = 1; i <= N; ++i)
{
part *= - x * x * (2 * (i - 1) + 1) / (2 * i + 1);
total_sum += part;
}
std::cout << "atan(" << x << ") = " << std::setprecision(16) << atan(x) << std::endl
<< "Aproximate = " << std::setprecision(16) << total_sum << std::endl;
}
}
system("pause");
return 0;
} |
|
1
|