   Program Kyrcovaya;
 uses crt, graph;
 var nPunkt, KeyAscii, a,iscreen, nstep: integer;
     Key: char;
     fx, x: array [0..1000] of real;
     Xmax, Xmin: integer;  step: real;
     Xmax1, Xmin1, Step1: String;
 Procedure Printvvod;
 begin
  clrscr;
 GoToXY(20,2);
 writeln('----------------------------------');
 GoToXY(20,3);
 writeln('!  Xmin    !  Xmax    !  Step    !');
 GoToXY(20,4);
 writeln('----------------------------------');
 GoToXY(20,5);
 writeln('! ',xmin:5,' ! ', xmax:5,' ! ', Step:5,' !');
 GoToXY(20,6);
 writeln('----------------------------------');

end;
 Procedure Oprogramme;
 begin
      clrscr;
      GoToXY(20,6);
      Writeln('Kyrcovaya rabota po informatike');
       GoToXY(20,7);
       Writeln('rasschitat znachenie funkcii i postroit grafic');
        GoToXY(20,8);
        Writeln('Vipolnila studentka gruppi St-110901');
          GoToXY(20,9);
          Writeln('Pupova Svetlana');
      Readln;
 end;
Procedure VvodDannih(var Xmin,Xmax: integer; var step:real);
Var m, i: integer;
Xmin1,Xmax1,Step1:string;

begin
clrscr;
     GoToXY(20,8);
     writeln ('vvedite Xmin:');
repeat
     readln(Xmin1);
     Val (Xmin1, Xmin,m);
     if (m<>0) or (Xmin<=0) then
     writeln ('ne verno, vvedite polozitelnoe chislo');
until (m=0) and (Xmin>0);

Printvvod;
clrscr;
     GoToXY(20,8);
     writeln ('vvedite Xmax:');
repeat
     readln(Xmax1);
     Val (Xmax1, Xmax, m);
     if m<>0 then
     begin
     writeln ('ne verno, vvedite chislo');
     end;
     until m=0;
 Printvvod;
     GoToXY(20,8);
     writeln ('vvedite shag:');
repeat
     readln(Step1);
     Val (Step1, Step, m);
     if m<>0 then
     begin
     writeln ('ne verno, vvedite chislo');
     end;
until m=0;

 Printvvod;
 repeat
 if Xmax<=Xmin then
               begin
               writeln('vvedite zanovo Xmin i Xmax');
               writeln('Xmax dolzen bit bolshe Xmin');
               Textcolor(Green);
               readln;
               clrscr;
               GoToXY(20,8);
              writeln ('vvedite Xmin:');
              repeat
                  readln(Xmin1);
                  Val (Xmin1, Xmin,m);
                 if m<>0 then
                     begin
                     writeln ('ne verno, vvedite chislo');
                     end;
             until m=0;
            Printvvod;
            clrscr;
            GoToXY(20,8);
            writeln ('vvedite Xmax:');
            repeat
            readln(Xmax1);

            Val (Xmax1, Xmax, m);
            if m<>0 then
              begin
              writeln ('ne verno, vvedite chislo');
            end;
            until m=0;
           Printvvod;

           readln;
           end;
until m=0;
writeln('vvoddannyh.xmin=',xmin,' xmax=',xmax, ' step=',step);
readln;
end;

procedure Raschet (Xmin, Xmax: integer;step: real;var nstep:integer; var x,fx: array of real; iscreen: integer) ;

var i: integer;

 begin

 clrscr;
 If iscreen=1 then
 begin
 writeln('Zadana funkcia: y(x)=(2*sin(x+2.5))/(15-ln(x))');
 writeln('1. oblast opredelenia funkcii:');
 writeln('15-ln(x)<>0, ln(x)<>15, x<>exp(15) - tochka razriva');
 writeln('sledovatelno x prinadlezit (-beskonechnost;exp(15))U(exp(15);+beskonechnost)');
 writeln('2. chetnost:');
 writeln('y(-x)=(2*sin(-x+2.5))/(15-ln(-x))<>y(x)<>y(-x)');
 writeln('=> y(x)-funksia obshego vida');
 writeln('3. tochki peresecheniya s osyami:');
 writeln('s osyu OY: x=0');
 writeln('ln(0) ne syshestvyet => net peresecheniya s OY');
 writeln('s osyu OX: y=0');
 writeln('2*sin(x+2.5)/(15-ln(x))=0, sin(x+2.5)=0');
 writeln('x=Pi*k-2.5');
 writeln('gde x prinadlezit {Pi*k-2.5|(k>=1)&(k prinadlezit N}');
 writeln('4. asimptoti:');
 writeln('x=exp(15) - vertikalnaya asimptota');
 readln;
 end;
 clrscr;
 nstep:=trunc((Xmax-Xmin)/Step+1);
 for i:=0 to nstep do
 if (x[i]<exp(15e0)-1e-10) or  (x[i]> exp(15e0)+1e-10) then
 begin

     x[i]:=xmin+i*step;
     fx[i]:=2*sin(x[i]+2.5)/(15-ln(x[i]));
     if iscreen=1 then writeln('x=', x[i]:10,' ','fx=', fx[i]:10);

 end
 else
 begin
 x[i]:=xmin+i*step;
 writeln('x=exp(15) - tochka razriva funksii');
 readln;

 end;
 readln;
 end;
 procedure graphic(xmin,xmax: integer);
 var i, gd,gm,npoint: integer; s: string;
     ymin,ymax,stepy: real;   fxg: array[0..610] of integer;
 begin
   Raschet (Xmin,Xmax,(xmax-xmin)/599,npoint, x,fx,0);
   writeln('npoint=',npoint); readln;
   ymin:=fx[0]; ymax:=fx[0];
   for i:=0 to npoint do
   begin
     if ymin>fx[i] then ymin:=fx[i];
     if ymax<fx[i] then ymax:=fx[i];
   end;
   stepy:= (ymax-ymin)/399;


   for i:=0 to npoint do
   begin

    fxg[i]:=round((fx[i]-ymin)/stepy);
   end;
   gd:=Detect;
   InitGraph(gd,gm,'');

   setcolor(Blue);
   line(35,400-round(-ymin/stepy),640,400-round(-ymin/stepy));
   setcolor(Yellow);
   line(39,480-70  , 39,10);
   setlinestyle(0,0,NormWidth);
   setcolor(Yellow);
   OutTextXY(20,15,'Y');
   line(40,400,640,400);
    setlinestyle(0,0,NormWidth);
   setcolor(Red);
    str(xmin:5,s);  s:='XMIN='+s;
    OutTextXY(10,440,s);
    str(xmax:5,s); s:='XMAX='+s;
    OutTextXY(550,440,s);
    str(ymax:9:3,s);
    OutTextXY(0,5,s);
    str(ymin:9:3,s);
    OutTextXY(0,390,s);
   for i:=1 to npoint do
    begin
     line(40+i-1,400-fxg[i-1],40+i,400-fxg[i]);

    end;
   readln;
   closegraph;
 end;
begin
    clrscr;
    a:= 6;
    nPunkt :=1;

 repeat
    clrscr;
    if nPunkt = 1 then TextColor(5) else TextColor(1) ;
    GoToXY(30,10);
    Writeln('Oprogramme');
      if nPunkt = 2 then TextColor(5) else TextColor(1) ;
    GoToXY(30,11);
    Writeln('VvodDannih');
      if nPunkt = 3 then TextColor(5) else TextColor(1) ;
    GoToXY(30,12);
    Writeln('Raschet');
      if nPunkt = 4 then TextColor(5) else TextColor(1) ;
    GoToXY(30,13);
    Writeln('Grafiá');
      if nPunkt = 5 then TextColor(5) else TextColor(1) ;
    GoToXY(30,14);
    Writeln('Vihod');

    Key := ReadKey;
    KeyAscii := Ord(Key);
    if KeyAscii = 0  then
    begin
        Key := ReadKey;
        KeyAscii := Ord(Key);
    end;
    if KeyAscii = 80  then nPunkt := nPunkt + 1;
    if KeyAscii = 72  then nPunkt := nPunkt - 1;

    if nPunkt > 5 then nPunkt := 1;
    if nPunkt < 1 then nPunkt := 5;
     if KeyAscii = 13 then
     begin
           iscreen:=1;
           if nPunkt = 1 then Oprogramme;
           if nPunkt = 2 then VvodDannih (Xmin,Xmax,Step);
           if nPunkt = 3 then Raschet (Xmin,Xmax,Step,nstep, x,fx,iscreen);
           if nPunkt = 4 then Graphic(xmin,xmax);
           if nPunkt = 5 then a:=5;
     end;

     { Writeln(KeyAscii); }
 until (KeyAscii = 113) or (a=5);
 end.