Advertisement
Tec4Gen

Untitled

Dec 2nd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include<iostream>
  2. #include<iomanip>
  3. using namespace std;
  4.  
  5. float f_u(float x, float e, int &n) {//Функция для просчета суммы для выбранной точки отрезка
  6. n = 2;
  7. float sum = 1, a = x;
  8. while (abs(a) >= e) {
  9. a *= (x*x)/(((2 * n - 1)) * 2);
  10. sum += a;
  11. n++;
  12.  
  13. }
  14. return sum;
  15. }
  16.  
  17.  
  18.  
  19.  
  20. int main() {
  21.  
  22. float a, b, h, e, x, f;
  23. int n, i = 1;
  24.  
  25. cout << "Enter a: ";
  26. cin >> a;
  27. cout << "Enter b: ";
  28. cin >> b;
  29. cout << "Enter step h: ";
  30. cin >> h;
  31. cout << "Enter epsilon: ";
  32. cin >> e;
  33. cout << "i" << '\t' << "x" << '\t' << "f(x)" << '\t' << "n" << endl;
  34.  
  35. for (i, x = a; x <= b; x += h, i++) {
  36. f = f_u(x, e, n);
  37. cout << i << '\t' << x << '\t' << f << '\t' << int(n - 2) << endl;
  38. }
  39.  
  40. system("pause");
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement