Программа построения графиков тригонометрических функций — Pascal(Паскаль)

Program cdcdf;
uses CRT,Graph;
var usr_input : Char;
 driver, mode: Integer;
x, y: real;
 
procedure cosin;
begin
driver:= Detect;
InitGraph(driver, mode, '');
SetBkColor(1);
line(50,0,50,480);
line(50,200,640,200);
moveto(50,200);
x:=1;
repeat
y:=cos(x);
lineto(50+round(x*50),100+(100-round(y*20))) ;
x:=x+0.02
until x>10;
settextstyle(0,0,1);
outtextxy(60,10,'y');
outtextxy(640,180,'x');
outtextxy(60,215,'0');
settextstyle(1,0,2);
outtextxy(150,320,'cos(x)');
Readln;
CloseGraph;
end;
procedure sinus;
begin
driver:= Detect;
InitGraph(driver, mode, '');
SetBkColor(1);
line(50,0,50,480);
line(50,200,640,200);
moveto(50,200);
x:=1;
repeat
y:=sin(x);
lineto(50+round(x*50),100+(100-round(y*20))) ;
x:=x+0.02
until x>10;
settextstyle(0,0,1);
outtextxy(60,10,'y');
outtextxy(640,180,'x');
outtextxy(60,215,'0');
settextstyle(1,0,2);
outtextxy(150,320,'sin(x)');
Readln;
CloseGraph;
end;
procedure tan;
begin
driver:= Detect;
InitGraph(driver, mode, '');
SetBkColor(1);
line(50,0,50,480);
line(50,200,640,200);
moveto(50,200);
x:=1;
repeat
y:=sin(x)/cos(x);
lineto(50+round(x*50),100+(100-round(y*20))) ;
x:=x+0.02
until x>10;
settextstyle(0,0,1);
outtextxy(60,10,'y');
outtextxy(640,180,'x');
outtextxy(60,215,'0');
settextstyle(1,0,2);
outtextxy(185,340,'tg(x)');
Readln;
CloseGraph;
end;
procedure cotang;
begin
driver:= Detect;
InitGraph(driver, mode, '');
SetBkColor(1);
line(50,0,50,480);
line(50,200,640,200);
moveto(50,200);
x:=1;
repeat
y:=cos(x)/sin(x);
lineto(50+round(x*50),100+(100-round(y*20))) ;
x:=x+0.02
until x>10;
settextstyle(0,0,1);
outtextxy(60,10,'y');
outtextxy(640,180,'x');
outtextxy(60,215,'0');
settextstyle(1,0,2);
outtextxy(90,340,'ctg(x)');
Readln;
CloseGraph;
end;
procedure kvadrat;
begin
driver:= Detect;
InitGraph(driver, mode, '');
SetBkColor(1);
line(50,0,50,480);
line(50,200,640,200);
moveto(50,200);
x:=1;
repeat
y:=sqr(x);
lineto(50+round(x*50),100+(100-round(y*20))) ;
x:=x+0.02
until x>10;
settextstyle(0,0,1);
outtextxy(60,10,'y');
outtextxy(640,180,'x');
outtextxy(60,215,'0');
settextstyle(1,0,2);
outtextxy(150,320,'sqr(x)');
Readln;
CloseGraph;
end;
procedure koren;
begin
driver:= Detect;
InitGraph(driver, mode, '');
SetBkColor(1);
line(50,0,50,480);
line(50,200,640,200);
moveto(50,200);
x:=1;
repeat
y:=sqrt(x);
lineto(50+round(x*50),100+(100-round(y*20))) ;
x:=x+0.02
until x>10;
settextstyle(0,0,1);
outtextxy(60,10,'y');
outtextxy(640,180,'x');
outtextxy(60,215,'0');
settextstyle(1,0,2);
outtextxy(150,320,'sqrt(x)');
Readln;
CloseGraph;
end;
 
procedure vixod;
begin
 closegraph;
 halt;
 exit;
end;
 
begin
  ClrScr;
  repeat
  REPEAT
    ClrScr;
    WriteLn('0. Grafik funktsiy cos(x) ');
    WriteLn('1. Grafik funktsiy cos(x) ');
    WriteLn('2. Grafik funktsiy sin(x)');
    WriteLn('3. Grafik funktsiy tg(x)');
    WriteLn('4. Grafik funktsiy ctg(x)');
    WriteLn('5. Grafik funktsiy sqr(x)');
    WriteLn('6. Grafik funktsiy sqrt(x)');
 
    GotoXY(1, 24);
    Write('Vuberit nomer grafika funktsiy [ ]');
    GotoXY(WhereX-2, WhereY);
    usr_input:=ReadKey;
 
  until (usr_input>='0') and (usr_input<='6');
 
  ClrScr;
       GotoXY(27, 8);
  WriteLn('Vu vibrali grafik. - ', usr_input);
 
    GotoXY(20, 10);
  WriteLn('Dlay prodovdjenay natusnit klavishu ENTER...');
  case usr_input of
  '1': cosin;
  '2': sinus;
  '3': tan;
  '4': cotang;
  '5': kvadrat;
  '6': koren;
  '0': vixod;
  end;
  WriteLn;
  until usr_input='e';
  WriteLn;
  ReadKey;
end.

Leave a Comment

+ 59 = 60