Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cmath>
  4. #include <windows.h>
  5. using namespace std;
  6.  
  7. int main ()
  8. {
  9. SetConsoleOutputCP(CP_UTF8);
  10. srand(time(NULL));
  11. double x = ((double)rand()) / ((double)RAND_MAX) * (-2) + 1;
  12. double e = 0, sum = 0;
  13. double a;
  14. int n = 1;
  15. cout << "Значение X: " << x << endl;
  16. cout << "Введите эпсилон: " << endl;
  17. cin >> e;
  18. cout << "Введите альфа: " << endl;
  19. cin >> a;
  20. double a0 = 1, a1 = a*x;
  21. sum += a0;
  22. while (fabs(a1) >= e / 10)
  23. {
  24. sum += a1;
  25. a0 = a1;
  26. /* for (int i = 1; i <= n+1; i++) {
  27. res = res * i;
  28. } */
  29. a1 = a1*(a-n)*x/(n+1);
  30. n++;
  31. }
  32. cout <<"Значение функции: "<< pow((1+x),a) << endl;
  33. cout << "Значение суммы ряда: "<< sum << endl;
  34.  
  35. system("pause");
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement