uses crt,graph;
const    a=0; b=1; dx=0.01; m=4; hmin=(b-a)/100000; hmax=(b-a)/4; hh=0.4;
    maxy=10; ms=50; mr=round(ms/m)+ms; mshx=15; mshy=70; Edop=0.001;
  var x1,h,D,P : real;
    x,y,y1 : array[1..150]of real;
    i,j,k : integer;
{===================================}
function f(x : real;y : real): real;
begin
 if x=0 then x:=0.001;
 f:=(y+sqrt(sqr(x)+sqr(y)))/x;
end;
{===================================}
procedure Koshi;
var e : real;
begin
  k:=1; x1:=a-h; y[k]:=-0.5; h:=(b-a)/10;
   writeln('Ŀ ');
   writeln('  k      X[k]   Y(x[k])   Y[k]  Y(x[k])-Y[k]=D  D/Y(x[k])*100    h  ');
   writeln('Ĵ');
  while x1<b do
  begin
   x1:=x1+h;
   y[k+1]:=y[k]+h*f(x1,y[k]);
   y1[k]:=(sqr(x1)-1)/2;
   E:=abs(D/7);
   D:=y1[k]-y[k];
   if E>EDOP then
   begin
    h:=h/2;
    if h<hmin then h:=hmin;
   end else begin
     y[k]:=y[k]+E;
   end;
   write('  ',k,'   ');
   write(x1:6:4,'  ');
   write(y1[k]:6:4,'  ' );
   write(y[k]:6:4,'  ');
   D:=y1[k]-y[k];
   write(D:6:6,'      ');
   if y1[k]=0 then y1[k]:=0.01;
   P:=(D/y1[k])*100;
   write(P:6:4,'        ');
   write(h:4:4,' ');
   writeln;
   k:=k+1;
   if k=21 then readkey;
   if k=100 then readkey;
  end;
  writeln('');
  readkey;
end;
{===================================}
procedure GRAFIK;
var
  gd,gm,x,yy,yyy,l1:integer;
  s:string;
begin
     gd:=EGA; gm:=1; initgraph(gd,gm,'');setcolor(white);
     yyy:=180; {!!!!!!!!!!!}
     l1:=30;  {!!!!!!!!!!!}
     line(20,yyy,getmaxx-20,yyy); { }
     line(l1,10,l1,getmaxy-10);   { }
     OutTextXY(l1-3,5,char(30));  {५ }
     OutTextXY(getmaxx-20,yyy-3,char(16));{५ }
     setcolor(15);outtextxy(getmaxx-10,yyy-3,'K');  { }
     outtextxy(l1+10,8,'Y');           { }
     {*=*=*=    *=*=*=*}
     setcolor(15);outtextxy(l1-9,yyy+5,'0');
     for i:=1 to 2*round(k+hh) do
     begin
          setcolor(2);
          line(l1+round((mshx*i){/2}),yyy-5,l1+round((mshx*i){/2}),yyy+5);
          line(l1-round((mshx*i){/2}),yyy-5,l1-round((mshx*i){/2}),yyy+5);
          str(i:1{(i-0.5*i):2:1},s); setcolor(15);
          outtextxy(l1+round((mshx*i){/2})-9,yyy+5,s);outtextxy(l1-round((mshx*i){/2})-20,yyy+5,'-'+s);
      end;
     {*=*=*=    *=*=*=*}
     for i:=1 to 2*maxy do
     begin
          setcolor(2);
          line(l1-5,yyy-round((mshy*i)/2),l1+5,yyy-round((mshy*i)/2));
          line(l1-5,yyy+round((mshy*i)/2),l1+5,yyy+round((mshy*i)/2));
           str((i-0.5*i):2:1,s); setcolor(15);
          outtextxy(l1-25,yyy-3-round((mshy*i)/2),s); outtextxy(l1-30,yyy-3+round((mshy*i)/2),'-'+s);
     end;
     {*=*=*=*=*=*=*=*=*=*=*=*=*}
     SetFillStyle(1,12);
     bar(380,10,385,15);
     SetFillStyle(1,10);
     bar(380,20,385,25);
     setcolor(15);outtextxy(390,10,'ਡ 襭');
     setcolor(15);outtextxy(390,20,'筮 襭');
     {*=*=*=*=*  Y=F(X)  *=*=*=*=*}
     setcolor(12);
     x1:=-1;
     for i:=1 to k do
     begin
           x1:=x1+1;
           x:=l1+round(x1*mshx); yy:=yyy-round(y[i]*mshy);
           if i=1 then moveto(x,yy);
           lineto(x,yy);
     end;
     {*=*=*=*=*  Y=F(X)  *=*=*=*=*}
     setcolor(10);
     x1:=-1;
     for i:=1 to k do
     begin
           x1:=x1+1;
           x:=l1+round(x1*mshx); yy:=yyy-round(y1[i]*mshy);
           if i=1 then moveto(x,yy);
           lineto(x,yy);
     end;
     readkey;
     Closegraph;
end;
{************************************}
BEGIN
 clrscr;
 textcolor(12);
 writeln('                   祭 ');
 textcolor(10);
 Koshi;
 GRAFIK;
END.