Uses CRT,GRAPH;
Const
  Eps = 0.01;
  Del = 6000;
  LeftGr = -100;
  RightGr = 100;
Procedure InitG;
Var
  grDriver: Integer;
  grMode: Integer;
  i : integer;
Begin
  grDriver := Detect;
  InitGraph(grDriver, grMode,'');
  SetFillStyle(XHatchFill,Green);
  Bar(0,0,GetMaxX,GetMaxY);
  SetFillStyle(SolidFill,Black);
  Bar(100,50,540,450);
  SetColor(Red);
  Line(100,250,540,250);
End;{InitG}
{--------------------------------}
Function Func(x: real): real;
Var
 ret: real;
Begin
  ret  := 30*(sin(45*x*pi/180))*cos(12*pi*x/180);
  Func := ret;
End;
{-----------------------------}
Procedure WriteGraph(l,r,Color:Integer);
Var
  x,y,Razm : Integer;
Begin
  Razm := r-l;
  SetColor(Color);
  MoveTo(100,250-Round(Func(l)));
  for x := L to R do
    begin
      y := round(Func(x));
      LineTo(round(100+(x-l)*((440)/razm)),250-y);
    end;
End;{WriteGraph}
{---------------------------------}
Function AddX(x : real):integer;
Begin
  AddX :=round(100+(x-leftGR)*((440)/(RightGr-LeftGr)));
End;
{-----------------}
Procedure Calculate;
Var
  R,L,dx,lx,b,k,x : real;
  str1 : string;
Begin
  R := RightGr;
  L := LeftGr;
  WriteGraph(round(L),round(R),Blue);
  x := r;
{  repeat
      setcolor(green);

  until dx < Eps;}
  setcolor(yellow);
  circle(addx(x),250,5);
  SetColor(Magenta);
  SetTextJustify(LeftText,Centertext);
  SetTextStyle(DefaultFont,HorizDir,4);
  OutTextXY(250,20,'Done');
  str(x:1:6,str1);
  SetTextStyle(Defaultfont,HorizDir,3);
  insert('X = ',str1,1);
  OutTextXY(150,440,str1);
End;
{------------------}
Begin
  InitG;
  Calculate;
  ReadKey;
  CloseGraph;
End.