Advertisement
dxvmxnd

Untitled

Oct 8th, 2024
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. double x, epsilon;
  7.  
  8. cout << "Введите значение x (в радианах): ";
  9. cin >> x;
  10. cout << "Введите точность ε: ";
  11. cin >> epsilon;
  12.  
  13. double term;
  14. term = x;
  15. double sum;
  16. sum = term;
  17. int n;
  18. n = 1;
  19.  
  20.  
  21.  
  22. while (fabs(term) >= epsilon) {
  23. term *= -x * x / ((2 * n) * (2 * n + 1));
  24. sum += term;
  25. cout << "sin(x) = " << sum << std::endl;
  26. n++;
  27. }
  28. cout << "Итоговый результат: ";
  29. cout << "sin(" << x << ") = " << sum << std::endl;
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement