Сам код:
#include
#include
#include
#include
using namespace std;
int main() {
double x, e, n;
string conexit = "continue", conexit1;
setlocale(LC_ALL, "Russian");
do {
a: cout << "Введите значение х : ";
cin >> x;
if ((x <= 0) || (x >= 1))
goto a;
b: cout << "Введите желаемую точность : ";
cin >> e;
if ((e <= 0) || (e >= 1))
goto b;
d: cout << "Введите необходимое число членов разложения n : ";
cin >> n;
if (n < 0)
goto d;
double s = 0, up, down, result, stepen;
int k = 1, koef, pum, fakt;
stepen = (x*x);
koef = 1;
pum = (2 * k * k + 1);
fakt = (1 * 2);
fakt = (fakt*(2 * k * k + 1)*(2 * k));
up = pum * stepen;
down = fakt;
result = koef * (up / down);
for (k = 2; abs(result) >= e; k++) {
s += result;
stepen *= stepen;
koef *= -1;
pum = (2 * k * k + 1);
fakt = (fakt*(2 * k * k+ 1)*(2 * k));
up = pum * stepen;
down = fakt;
result = koef * (up / down);
}
cout << "Сумма ряда S равна : " << s << endl;
k = 1;
double s2 = 0, up1, down1, result1, stepen1, fakt1;
int koef1, pum1;
stepen1 = (x*x);
koef1 = 1;
pum1 = (2 * k * k + 1);
fakt1 = (1 * 2);
fakt = (fakt*(2 * k * k + 1)*(2 * k));
up1 = pum1 * stepen1;
down1 = fakt1;
result1 = koef1 * (up1 / down1);
for (k = 2; k <= n; k++) {
s2 += result1;
stepen1 *= stepen1;
koef1 *= -1;
pum1 = (2 * k * k + 1);
fakt1 = (fakt1*(2 * k * k + 1)*(2 * k));
up1 = pum1 * stepen1;
down1 = fakt1;
result1 = koef1 * (up1 / down1);
}
double c;
c = (1 + (x / 2) * sin(x) + (((x * x)/2) - 1) * cos(x));
cout << "Результат контрольного выражения C равен : " << c << endl;
cout << "Для повтора вычислений введите continue ,";
cout << " для выхода - любую другую фразу или букву/цифру : ";
cin >> conexit1;
} while (conexit1 == conexit);
return 0;
}
