Uses crt;
Var
a,b,h,i1,e,i2,t:real;
n,i,k:longint;
function f(x:real):real;
begin
f:=sin(x);
end;
function Simp(x:real;r:byte):real;
Var
s:real;
begin
s:=0;
for i:=1 to n-1 do
begin
if (i mod 2=r) then
s:=s+f(x)
else;
x:=x+h;
end;
Simp:=s;
end;
begin
a:=pi/4;
b:=pi/2;
e:=0.000001;
n:=2;
k:=0;
repeat
i2:=i1;
i1:=((1/3)*h)*(f(a)+f(b)+4*Simp(a+h,1)+2*Simp(a+h,0));
n:=n*2;
h:=(b-a)/n;
k:=k+1;
until abs(i1-i2)<e;
Writeln;
Writeln;
textcolor(blue);
i1:=abs(i1);
Writeln('znashenie ploshadi metodom Simpsona *= ');
Write(i1:0:6,' toshek deleni9 ',n);
writeln;
write('Kol-vo iterracci= ',k,' ');
Readkey
end.