home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Action 54
/
cdactioncoverdisc54.iso
/
Bonus
/
pascal.exe
/
prog097.pas
< prev
Wrap
Pascal/Delphi Source File
|
2000-09-15
|
4KB
|
178 lines
program program097;
uses crt,graph;
var sterownik,tryb:integer;
xl,yl,i,wyb,y:integer;
x,a,b,c,d:real;
procedure init;
begin
sterownik:=9;
tryb:=2;
initgraph(sterownik,tryb,'c:\...\bgi');
end;
procedure dane;
begin
clrscr;
if wyb=1 then writeln('Postaå funkcji y=(a*sin(bx+c))+d') else
writeln('Postaå funkcji y=(a*cos(bx+c))+d');
writeln;
write('Podaj a: ');readln(a);
write('Podaj b: ');readln(b);
write('Podaj c: ');readln(c);
write('Podaj d: ');readln(d);
end;
procedure legendsin;
begin
setcolor(4);
outtextxy(10,420,'Funkcja sinus pierwotna.');
setcolor(12);
outtextxy(10,430,'Funkcja sinus przeksztaêcona.');
end;
procedure legendcos;
begin
setcolor(14);
outtextxy(10,400,'Funkcja cosinus pierwotna.');
setcolor(10);
outtextxy(10,410,'Funkcja cosinus przeksztaêcona.');
end;
procedure wykres;
begin
for i:=0 to 639 do begin putpixel(i,179,7); i:=i+3; end;
for i:=0 to 639 do begin putpixel(i,299,7); i:=i+3; end;
setcolor(8);
line(0,0,639,0);
line(0,479,639,479);
line(0,0,0,479);
line(639,0,639,479);
setcolor(15);
line(319,0,319,479);
line(0,239,639,239);
outtextxy(322,244,'0');
outtextxy(385,244,chr(20));
outtextxy(395,244,'/2');
outtextxy(475,244,chr(20));
outtextxy(548,244,'3/2');
outtextxy(573,244,chr(20));
outtextxy(620,244,'2');
outtextxy(630,244,chr(20));
outtextxy(217,244,'-');
outtextxy(225,244,chr(20));
outtextxy(235,244,'/2');
outtextxy(147,244,'-');
outtextxy(155,244,chr(20));
outtextxy(60,244,'-3/2');
outtextxy(95,244,chr(20));
outtextxy(2,244,'-2');
outtextxy(20,244,chr(20));
outtextxy(329,179,'1');
outtextxy(328,299,'-1');
setcolor(15);
line(79,236,79,242);
line(159,236,159,242);
line(239,236,239,242);
line(319,236,319,242);
line(399,236,399,242);
line(479,236,479,242);
line(559,236,559,242);
line(316,179,322,179);
line(316,299,322,299);
setcolor(15);
outtextxy(316,0,'^');
outtextxy(632,236,'>');
outtextxy(326,0,'Y');
outtextxy(632,227,'X');
end;
procedure sinus;
begin
moveto(0,239);
setcolor(12);
for i:=1 to 640 do
begin
x:=(i*pi)/180;
y:=round(-60*a*sin((x*b*1.126+c*60))+d*(-60));
if i<>1 then line(xl,yl,i,y+239);
xl:=i;
yl:=y+239;
end;
end;
procedure sinus1;
begin
moveto(0,239);
setcolor(4);
for i:=1 to 640 do
begin
x:=(i*pi)/180;
y:=round(-60*sin(x*1.126));
if i<>1 then line(xl,yl,i,y+239);
xl:=i;
yl:=y+239;
end;
end;
procedure cosinus;
begin
moveto(0,239);
setcolor(2);
for i:=1 to 640 do
begin
x:=(i*pi)/180;
y:=round((-60*a*cos((x*b+c)*1.126))+d*(-60));
if i<>1 then line(xl,yl,i,y+239);
xl:=i;
yl:=y+239;
end;
end;
procedure cosinus1;
begin
moveto(0,239);
setcolor(14);
for i:=1 to 640 do
begin
x:=(i*pi)/180;
y:=round(-60*cos(x*1.126));
if i<>1 then line(xl,yl,i,y+239);
xl:=i;
yl:=y+239;
end;
end;
procedure wybor;
begin
writeln;
writeln('Wybierz interesujÑcÑ Ci⌐ f-cj⌐ trygonometrycznÑ :');
writeln('1 - sinus. ');
writeln('2 - cosinus. ');
write('Twój wybór: ');
readln(wyb);
dane;
init;
setbkcolor(0);
wykres;
if wyb=1 then
begin
sinus;
sinus1;
legendsin;
end;
if wyb=2 then
begin
cosinus;
cosinus1;
legendcos;
end;
end;
begin
clrscr;
wybor;
readkey;
closegraph;
end.