Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<iostream>
- #include<math.h>
- #include <iomanip>
- using namespace std;
- void r(double x,double x2)
- {
- double s, n, eps;
- int i;
- eps = 0.00001; // точность
- double e = 0.1; // шаг
- for (double j = x; j < x2; j += e)
- {
- n = 1;
- s = 0;
- i = 1;
- while (abs(n) > eps)
- {
- s += n;
- n *= -1.0 * j * j / ((2 * i - 1) * (2 * i));
- i++;
- }
- if (j > -0.01 && j < 0.01)cout << "x = " << 0 << " Сумма: " << s << " cos(x): " << cos(j) << endl;
- else
- cout << "x = " << left << setw(10) << j << "Сумма: " << setw(15) << s << "cos(x): " << setw(10) << cos(j) << endl;
- }
- }
- void main()
- {
- setlocale(LC_ALL, "rus");
- double x,x2;
- cout << "Введите число х\n";
- cin >> x;
- cout << "Введите число х2\n";
- cin >> x2;
- r(x,x2);
- }
Advertisement
Add Comment
Please, Sign In to add comment