Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <locale.h>
- #define abs(x) (((x) < 0) ? -(x) : (x))
- //Проверить значение eps
- int main(void) {
- setlocale(LC_ALL, "Russian");
- double x = 0.3, elem = (x * x * x) / 3, s = elem, eps = 10e-6;
- int cnt = 1;
- for (; abs(elem) > eps; ++ cnt) {
- int n = cnt + 1;
- elem *= -(x * x * (2 * n - 3)) / (2 * n + 1);
- s += elem;
- }
- printf("Количество вошедших в сумму элементов ряда: %d\nСумма элементов ряда с точностью %.5f: %f\n", cnt, eps, s);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment