{$N+} function y(const a,b,x: double): double; begin if x<-pi/2 then y:=(x-a)/(pi/2+a) else if x<pi/2 then y:=sin(x) else y:=1; end; var a,b,h,e,ip,ic: double; i,n: longint; begin writeln('a=?'); readln(a); writeln('b=?'); readln(b); writeln('точность=?'); readln(e); ic:=0; n:=16; h:=(b-a)/n; for i:=0 to n-1 do ic:=ic+y(a,b,a+i*h); ic:=ic*h; repeat ip:=ic; ic:=0; for i:=0 to n-1 do ic:=ic+y(a,b,a+i*h+h/2); ic:=(ic*h+ip)/2; n:=n*2; h:=(b-a)/n; until abs(ic-ip)<e; writeln('результат=',ic:6:6); readln; end. |