Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <iostream>
- #include <math.h>
- #include <iomanip>
- #include <conio.h>
- using namespace std;
- typedef double (*func)(double);
- double y_from_x (double);
- double s_from_x(double);
- void Out_Rez(double, double, double, func);
- double n;
- double s_from_x(double a) {
- double sx = 1;
- double shag = 1;
- for (double k = 1; k <= n; k++)
- {
- shag *= -1 * a * a / 2.0 / k / (2 * k - 1);
- sx += shag * (2 * k * k + 1);
- }
- return sx;
- }
- double y_from_x (double a) {
- return (1 - a * a / 2.) * cos(a) - a / 2. * sin(a);
- }
- void Out_Rez(double a, double b, double h, func f) {
- for (double x = a; x <= b; x += h) {
- cout << setw(15) << f(x) << endl;
- }
- }
- int main() {
- setlocale(LC_ALL, "");
- double a, b, h;
- cout << "Введите а\n";
- cin >> a;
- cout << "Введите b\n";
- cin >> b;
- cout << "Введите шаг\n";
- cin >> h;
- cout << "Введите n";
- cin >> n;
- Out_Rez( a, b, h, y_from_x);
- cout << "--------------------------------------------------------------------------------"<< endl;
- Out_Rez(a, b, h, s_from_x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement