Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <math.h>
- double f1(double x)
- {
- return x*x;
- }
- double f2(double x)
- {
- return x*x*x;
- }
- double integral2(double a, double b, int n, double (*f) (double))
- {
- double INTGRL = 0.0;
- double h = double((b - a) / n);
- for (double x = a; x <= b; x += h)
- {
- INTGRL += f(x - h / 2);
- }
- return INTGRL *= h;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- double a, b; int n;
- scanf_s("%lf %lf %d", &a, &b, &n);
- printf("%lf", integral2(a,b,n,sin));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement