procedure grafik(a,dX,b:real);
var i,gd,gm,p,x0,y0,u,t:integer;
pt,s:string;
x,y:array[1..300]of real;
q,w:array[1..300]of integer;
msh:real;
e:char;
Begin
gotoxy(20,3);
writeln('Plotting functions');
gotoxy(20,5);
writeln('y=(7x^2+1.5x-15)/(x+2)');
gd:=detect;
Initgraph(gd,gm,pt);
x0:=getmaxX div 2;
y0:=getmaxY div 2; {nachalo koord}
outtextXY(x0-20,50,'Y');
outtextXY(getmaxX-100,y0+20,'X');
outtextXY(x0-10,y0+10,'0');
outtextXY(x0-70,17,'Plotting functions');
outtextXY(x0-86,28,'y=(7x^2+1.5x-15)/(x+2)');
line(100,y0,getmaxx-100,y0);
line(x0,50,x0,getmaxy-50);
line(x0,50,x0+15,70);
line(x0,50,x0-15,70);
line(getmaxX-100,y0,getmaxX-120,y0+15);
line(getmaxX-100,y0,getmaxX-120,y0-15);
if abs(ymin)>abs(ymax) then msh:=10*(abs(ymin)/(getmaxy));
if abs(ymin)<abs(ymax) then msh:=10*(abs(ymax)/(getmaxy));
n:=trunc((b-a)/dX);
x[1]:=a;
y[1]:=-(7*x[1]*x[1]+1.5*x[1]-15)/(x[1]+2);
x[n]:=b;
y[n]:=-(7*x[n]*x[n]+1.5*x[n]-15)/(x[n]+2);
q[1]:=round(x[1]*msh);
q[n]:=round(x[n]*msh);
w[1]:=round(y[1]*msh);
line(x0+q[1],y0-w[1],x0+q[2],y0-w[2]);
{for i:=2 to n-1 do begin
x:=x[i-1]+dX;
q:=round(x*msh);
y:=(7*x*x+1.5*x-15)/(x+2);
w:=round(y*msh);
line(x0+q,y0-w,x0+q[i+1],y0-w[i+1]);
end;}
p:=round((getmaxX-200)/(b-a));
u:=round(a);
t:=round(dX);
line(x0+u*p,y0-10,x0+u*p,y0+10);
for i:=1 to trunc((b-a)/dX) do
line(x0+u*p+t*i,y0-10,x0+u*p+t*i,y0+10);
if abs(ymin)>abs(ymax) then msh:=10*(abs(ymin)/(getmaxy));
if abs(ymin)<abs(ymax) then msh:=10*(abs(ymax)/(getmaxy));
k:=0;
x[1]:=a;
q[1]:=round(x[1]*msh);
for i:=2 to n-1 do begin
x:=x[i-1]+dx;
q:=round(x*msh);
end;
x[n]:=b;
q[n]:=round(x[n]*msh);
for i:=1 to n do
begin
if (-2.01<x)and(x<-1.99) then k:=i else
y:=-(7*x*x+1.5*x-15)/(x+2);
line(x0+q,y0-w,x0+q[i+1],y0-w[i+1]);
if k=0 then
w:=round(y*msh);
line(x0+q,y0-w,x0+q[i+1],y0-w[i+1]);
end;
if k=0 then
for i:=1 to n-1 do
begin
w:=round(y*msh);
line(x0+q,y0-w,x0+q[i+1],y0-w[i+1]);
end;
{if k=1 then
for i:=2 to n-1 do
begin
w:=round(y*msh);
line(x0+q,y0-w,x0+q[i+1],y0-w[i+1]);
end;
}if k>0 then
begin
for i:=1 to k-2 do
begin
w:=round(y*msh);
line(x0+q,y0-w,x0+q[i+1],y0-w[i+1]);
end;
for i:=k+1 to n-1 do
begin
w:=round(y*msh);
line(x0+q,y0-w,x0+q[i+1],y0-w[i+1]);
end;
end;
readln;
closegraph;
e:=readkey;
clrscr;
case ord(e) of
27:exit;
end;
end;