V? d? th? h�nh sin |
Post Reply |
Author | |
Poster
Guest Joined: 23 January 2008 Status: Offline Points: 378 |
Post Options
Thanks(0)
Posted: 21 August 2008 at 20:00 |
PROGRAM VE_DO_THI_HAM_SO_SIN;
USES
CRT, GRAPH;
VAR
I,M1,M2,dvx,dvy:integer;
Device,Mode,X0,Y0,P,Q:integer;
Nr: String;
BEGIN
ClrScr;
InitGraph(Device,Mode,'C:\tp70\bgi');
If GraphResult<>0 then
Begin
Write('Loi do hoa! ', GraphErrorMsg(GraphResult) );
Exit;
End;
m1:=GetMaxX; m2:=GetMaxY;
dvx:=64;{ m1 div 10;}
dvy:=48;{ m2 div 10;}
x0:= 2* dvx;
y0:= 4* dvy ;
{ Ve 2 truc toa do }
Line (dvx,y0,9*dvx,y0); { Truc Ox}
Line (x0,dvy,x0,7*dvy); { Truc Oy}
{ V� c�c v�ch chia ��n v� tr�n tr�c Ox}
for i:=1 TO 6 DO
LINE (X0+Dvx*I, Y0-2, X0+Dvx*I, Y0+2);
for i:=1 TO 6 DO { ��nh s� tr�n tr�c Ox}
begin
Moveto(x0+dvx*i-3, y0+12); { l�i 3 �� ch� s� ��� x�ng v�i v�ch}
Str(i,Nr);
outtext(Nr);
end;
Moveto(x0+dvx*7-13, y0-12);
outtext('x');
{ V� c�c v�ch chia ��n v� tr�n tr�c Oy}
for i:=2 TO 6 DO
LINE (X0-2, dvy*i, X0+2, dvy*i);
{ ��nh s� tr�n tr�c Oy}
for i:=-2 to 2 do
Begin
Moveto(x0-40,y0-i*dvy-3);
Str((i* 0.5):3:1,Nr);
If i<0 then Outtext(Nr) else if i>0 then Outtext(' '+Nr);
End;
Moveto(x0-10,y0-3*dvy+5); outtext('Y');
{ V� �� th� h�m s� SIN v�i h� s� t� l� an-pha = PI/2 dvx, be-ta=2dvy }
for i:=0 to 7*dvx do
PutPixel (x0+i,y0-trunc(2*dvy*sin(i*pi/(2*dvx)) ),yellow );
Moveto(250, 350);
Outtext(' Do thi ham so Y = SIN(X)');
readln;
CloseGraph;
END.
|
|
Sponsored Links | |
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |