program nintegrace; const n=10; {const n=100;} function f(x:real):real; begin f:=exp(x); { f:=sin(x)*sin(x)*sin(x); } end; function lichobeznik(n:integer; a,b:real):real; var h, suma:real; xh: real; i: integer; begin h:=(b-a)/n; suma:=0; for i:=1 to n-1 do begin xh:=a+i*h; suma:=suma+h*f(xh); end; suma:=suma+h/2*(f(a)+f(b)); lichobeznik:=suma; end; function Simpson(n:integer; a,b:real):real; var h, suma, k:real; xh: real; i: integer; begin h:=(b-a)/n; suma:=0; for i:=1 to n-1 do begin xh:=a+i*h; if (i mod 2) = 1 then k:=4/3 else k:=2/3; suma:=suma+h*k*f(xh); end; suma:=suma+h/3*(f(a)+f(b)); Simpson:=suma; end; function obdelnik(n:integer; a,b:real):real; var h, suma:real; xh: real; i: integer; begin h:=(b-a)/n; suma:=0; for i:=1 to n do begin xh:=a+i*h-h/2; suma:=suma+h*f(xh); end; obdelnik:=suma; end; begin { writeln(lichobeznik(n,1.0,5.0));} { writeln(Simpson(n,1.0,5.0));} writeln(obdelnik(n,1.0,5.0)); readln; end.