Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "ru");
- long float eps = 0.00001;
- int k = 0;
- long float sum = 0;
- long float sum1;
- long float fact = 1;
- int a = 1;
- long float x;
- do
- {
- cin >> x;
- } while (x == 0);
- do
- {
- sum1 = sum;
- double numerator = a * pow(x, 4 * k + 1); //numerator - числитель
- double denumerator = fact * (4 * k + 1); //denumerator - знаменатель (разделил, чтобы легче было искать ошибку)
- sum += numerator / denumerator;
- a = -a;
- k++;
- fact *= 2 * k;
- } while (abs(sum - sum1) > eps && isinf(sum) == 0);
- cout << "Вычисление суммы закончилось на [" << k << "] элементе, сумма в этот момент = " << sum1 << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement