Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include "locale.h"
- #include "math.h"
- void main() {
- setlocale(LC_ALL, "rus");
- double x, eps, fx, n = 0, Sn = 1, s, a = -1;
- do {
- printf_s("Введите x, -1 < x < 1: ");
- scanf_s("%lf", &x);
- printf_s("Введите eps: ");
- scanf_s("%lf", &eps);
- } while ((fabs(x) >= 1) || (eps < 0) || (eps > 1));
- fx = sqrt(1 + x);
- s = Sn;
- while ((fabs(fx - s) > eps) && (n < 100000)) {
- n++;
- a *= -1;
- Sn *= (a*((2*n-1)*(2*n))/(4*n*n*((1-2*n)/(-(1-2*(n-1))))))*x;
- s += Sn;
- }
- printf("fx = %12.10lf\ns = %12.10lf\nn = %12.10lf", fx, s, n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement