Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <math.h>
- #include <iomanip>
- using namespace std;
- typedef double(*uf)(double *, int *);
- void tabl(double*, double*, double*, int*, uf);
- double y(double *, int *);
- int main()
- {
- double a = 0.55, b = 1.4, h = (b - a) / 10; int n = 15;
- cout << setw(8) << "x" << setw(15) << "y(x,n)" << endl;
- tabl(&a, &b, &h, &n, y);
- return 0;
- }
- void tabl(double *a, double *b, double *h, int *n, uf fun)
- {
- double sum;
- for (double x = *a; x < *b + *h / 2; x += *h)
- {
- sum = fun(&x, n);
- cout << setw(8) << x << setw(15) << sum << endl;
- }
- }
- double y(double *x, int *n)
- {
- double sum = 0, b = *n + 1 / 2;
- for (int i = 1; i < b; i++)
- sum += pow(sin(i), 2) - 3 * exp(*x*i);
- return sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement