| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- Uses CRT,GRAPH,Strcalc;
- Const
- Eps = 0.001;
- Del = 5000;
- Frames = 1000;
- Var
- Fn:string;
- LeftGr : real;
- RightGr : real;
- Procedure InitG;
- Var
- grDriver: Integer;
- grMode: Integer;
- i : integer;
- Begin
- grDriver := Detect;
- InitGraph(grDriver, grMode,'');
- { SetWriteMode(XORPut);}
- 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 := StrFunc(fn,x);
- Func := ret;
- End;
- {-----------------------------}
- Procedure WriteGraph(l,r:real;Color:Integer);
- Var
- x,y : Integer;
- razmx,razmy,max,min: real;
- Begin
- Razmx := r-l;
- SetColor(Color);
- min := maxint;
- min := -maxint;
- for x := 1 to Frames do
- begin
- y := round(Func(l+(x/Frames)*razmx)*10);
- if y < min then min := y;
- if y > max then max := y
- end;
- razmy := max-min;
- MoveTo(100,250-Round(-200+((Func(l)-min)/razmy*400)));
- for x := 1 to Frames do
- begin
- Y:=Round(-200+((Func(l+(x/Frames)*razmx)-min)/razmy*400));
- LineTo(100+round(x/Frames*440),250-y);
- end;
- End;{WriteGraph}
- {---------------------------------}
- Begin
- Write('Enter function: ');
- ReadLn(fn);
- Read(LeftGr,RightGr);
- InitG;
- WriteGraph(leftGr,RightGR,Blue);
- ReadKey;
- CloseGraph;
- End.
|