program T1(input,output);
const eps=0.001;
type TF=function(x:real):real;
var  resulte,f12,f23,f13:real;

{$F+}
 function f1(x:real):real; begin f1:=0.6*x+3 end;
 function f2(x:real):real; begin f2:=(x-2)*(x-2)*(x-2)-1 end;
 function f3(x:real):real; begin f3:=3/x end;
 
procedure root(f,g:TF; a,b:real; var x:real);
  const eps1=0.0001;
var c,h,fb,fa,fh,fm,fc:real; d:boolean;
 begin
  repeat
   fb:=f(b)-g(b);
   fa:=f(a)-g(a);
   c:=(a*fb-b*fa)/(fb-fa);
   h:=(a+b)/2;
   fh:=f(h)-g(h);
   fm:=(fa+fb)/2;
   fc:=f(c)-g(c);    
  if fa*fc<=0 then b:=c
        else a:=c;
  until abs(fc)<=eps1;
 x:=c
 end;


function integral(f:TF; a,b:real):real;
const eps2=0.00001;
var h,Iss,Ipred,Fi,It:real; n0,i:integer;
 begin
 Iss:=0; 
 It:=0; 
 n0:=50;
  repeat
   Ipred:=Iss;{In}
   h:=(b-a)/n0;
   it:=0;
   for i:=0 to pred(n0) do
    begin
     Fi:=f(a+(i+0.5)*h);
     It:=Fi+It
    end;
   Iss:=It*h;
   n0:=n0*2;
  until abs((Ipred-Iss)/3)<=eps2;
 integral:=Iss
 end;

begin
root(f1,f2,3.5,4,f12);
root(f2,f3,3,3.5,f23);
root(f1,f3,0.5,1.5,f13);
resulte:=(integral(f1,f13,f23)-integral(f3,f13,f23))+(integral(f1,f23,f12)-integral(f2,f23,f12));
writeln('Roots: f12: ',f12:1:5);
writeln('       f23: ',f23:1:5);
writeln('       f13: ',f13:1:5);
writeln('Square of figure: ',resulte:1:5)
end.
