Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5. int main() {
  6. setlocale(LC_ALL, "Ru");
  7. double epsilon, alpha, x, frac = 1, ans = 1;
  8. cout << "Введите точность (эпсилон): ";
  9. cin >> epsilon;
  10. cout << "Введите степень: ";
  11. cin >> alpha;
  12. srand((LC_TIME, NULL));
  13. x = sin(rand());
  14. double n = 1;
  15. while (abs(frac) > epsilon)
  16. {
  17. frac = frac * ((alpha - n + 1)*x)/n;
  18. ans += frac;
  19. n++;
  20. }
  21. cout << " x = " << x << endl;
  22. cout << " (1+x)^a = " << endl;
  23. cout << "Значение суммы ряда: " << ans << endl;
  24. cout << "Значение встроенной функции: " << pow(1+x, alpha) << endl;
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement