include stdafx include math include windows define 40 double func_1 do

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "stdafx.h"
#include <math.h>
#include <windows.h>
#define N 40
double func_1(double m)
{
return sqrt(m*m-2)/m;
}
double func_2(double m)
{
return sin(m)*sin(m)*sin(m);
}
double Integral(int q, double a, double b, double (*func)(double))
{
double h,s,t;
int i;
h=(b-a)/q; //считаем шаг
for (s=0,i=0;i<q;i++) // счетчик
s+=func(a+h*i);
return s*=h; //исправить для своего !
}
int main(void)
{
printf("Integral 1 = %lf\n",Integral(N,2,7,func_1));
printf("Integral 2 = %lf\n",Integral(N,-3,1.5,func_2));
system("PAUSE");
return 0;
}