Поставленная задача:
Я пытался ее решить, но ничего не выходит увы...
Код:
uses crt;
type tFunct=function(x:real):real;
var sum:real;{peremennaja summi}
x,y,z,e,{-peremennije po usloviju}
a1,a2,b1,b2{intervali dlja functij},
Integ1,Integ2 {-Rezultati rascheta integralov}: real;
{Functija (x^2-1)*10^-2*x}
function f1(x:real):real;far;
var tmp:real;
i:integer;
begin
tmp:=1;
for i:=1 to 3 do tmp:=tmp*((x^2-1)*10^-2*x);
f1:=tmp;
end;
{Functija 1/(ln(x))^2}
function f2(x:real):real;far;
var tmp:real;
i:integer;
begin
tmp:=1;
for i:=1 to 3 do tmp:=tmp*x;
f2:=tmp*1/(x*ln(x)^2);
end;
{Integral}
function integr (x,y,e:real;F:tFunct):real;
var di,dx,sum1,sum2:real;
n:longint;
zf1,zf2,min,max:real;
dd:integer;
begin
di:=y-x; {Dlina intervala}
n:=10; {Nachalnoje znachenije kol-va intervalov}
repeat
dx:=di/n;
sum1:=0; sum2:=0;
z:=x;
while z<y do
begin
zf1:=F(z);zf2:=F(z+dx);
if zf1<zf2 then begin min:=zf1;max:=zf2;end
else begin min:=zf2;max:=zf1;end;
sum1:=sum1+dx*min;
sum2:=sum2+dx*max;
z:=z+dx;
{----v processe.... dlja polzovatelja}
dd:=dd+1;
case dd of
1:write('\');
2:write('|');
3:write('/');
4:write('-');
else
begin dd:=0;write('\');end;
end;
gotoxy(WhereX-1,WhereY);
{----------------------}
end;
write('.');
n:=2*n;
until abs(sum2-sum1)<e;
integr:=sum1;
writeln;
end;
{osnovnaja programma}
begin
clrscr;
repeat
write('Vvedite tochnost vichislenija integrala e: ');
readln(e);
until e>0;
writeln('Po usloviju A1=0 i B1=0.4');
repeat
write('Vvedite interval A..B dlja pervogo integrala: ');
readln(a1,b1);
until a1<b1;
writeln('Po usloviju A2=2.0 i B2=2.5');
repeat
write('Vvedite interval A..B dlja vtorogo integrala: ');
readln(a2,b2);
until a2<b2;
write('Podozhdite idet raschet');
Integ1:=integr(a1,b1,e,f1);
writeln('Integral ot ((x^2-1)*10^-2*x) = ',integ1:12:6);
write('Podozhdite idet raschet');
Integ2:=integr(a2,b2,e,f2);
writeln('Integral ot 1/x*(ln(x))^2 = ',integ2:12:6);
write('Dlja prodolzhenija mazhmite Enter...');
readkey;
end.
Сообщение отредактировано: volvo -