Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. double x, eps, sum = 0.0;
  8. do {
  9. cout << "Введите x = ";
  10. cin >> x;
  11. if (x == 0) {
  12. cout << "Неверное значение x\n";
  13. }
  14. } while (x == 0);
  15. do {
  16. cout << "Введите eps = ";
  17. cin >> eps;
  18. if (eps <= 0 || eps >= 1) {
  19. cout << "Неверное значение eps\n";
  20. }
  21. } while (eps <= 0 || eps >= 1);
  22. double u = 1;
  23. int k = 1;
  24. do {
  25. if (k == 1) {
  26. cout << "U0 = 0\n";
  27. }
  28. else {
  29. u *= (-x * x) * pow(k - 1, 3) / (pow(k, 3) * (k + 1));
  30. sum += u;
  31. cout << "U" << (k - 1) << " = " << u << endl;
  32. }
  33. k++;
  34. } while (abs(u) > eps);
  35. cout << "Сумма ряда = " << sum << "; Количество элементов = " << (k - 1) << endl;
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement