Namangan viloyat Kosonsoy tuman xtbga qarashli


Download 1.69 Mb.
Sana28.05.2020
Hajmi1.69 Mb.

Namangan viloyat Kosonsoy

tuman XTBga qarashli

28-maktab o’quvchisi

Husniddinova Dilnavoz

Mavzu: PascalABCda muntazam ko’pburchak yasash.

Muntazam ko’pburchak yasashni o’rganishdan avval muntazam uchburchak, muntazam to’rtburchak, muntazam beshburchak va muntazam oltiburchak yasashni ko’rib chiqamiz. Keyin hamma o’rganganlarimizni umumlashtirib, muntazam ko’pburchak yasaymiz.

program uchburchak; uses graphabc;

var x1,y1,x2,x3,y2,y3:integer;

begin

x1:=trunc(320+cos(-pi/2)*100);

y1:=trunc(200+sin(-pi/2)*100);

x2:=trunc(320+cos(-7*pi/6)*100);

y2:=trunc(200+sin(-7*pi/6)*100);

x3:=trunc(320+cos(pi/6)*100);

y3:=trunc(200+sin(pi/6)*100);

setpenwidth(5); setpencolor(clblue);

line(x1,y1,x2,y2); line(x2,y2,x3,y3);

line(x3,y3,x1,y1); end.

program to’rtburchak; uses graphabc;

var x1,y1,x2,x3,y2,y3,x4,y4:integer; begin

x1:=trunc(320+cos(3*pi/4)*100);

y1:=trunc(200+sin(3*pi/4)*100);

x2:=trunc(320+cos(5*pi/4)*100);

y2:=trunc(200+sin(5*pi/4)*100);

x3:=trunc(320+cos(7*pi/4)*100);

y3:=trunc(200+sin(7*pi/4)*100);

x4:=trunc(320+cos(9*pi/4)*100);

y4:=trunc(200+sin(9*pi/4)*100);

setpenwidth(5); setpencolor(clblue);

line(x1,y1,x2,y2); line(x2,y2,x3,y3);

line(x3,y3,x4,y4); line(x1,y1,x4,y4);

end.

program beshburchak; uses graphabc;

var x1,y1,x2,x3,y2,y3,x4,y4,x5,y5:integer;

begin

x1:=trunc(320+cos(-pi/10)*100);

y1:=trunc(200+sin(-pi/10)*100);

x2:=trunc(320+cos(3*pi/10)*100);

y2:=trunc(200+sin(3*pi/10)*100);

x3:=trunc(320+cos(7*pi/10)*100);

y3:=trunc(200+sin(7*pi/10)*100);

x4:=trunc(320+cos(11*pi/10)*100);

y4:=trunc(200+sin(11*pi/10)*100);

x5:=trunc(320+cos(15*pi/10)*100);

y5:=trunc(200+sin(15*pi/10)*100);

setpenwidth(5); setpencolor(clblue);

line(x1,y1,x2,y2);line(x2,y2,x3,y3);

line(x3,y3,x4,y4);line(x5,y5,x4,y4);

line(x5,y5,x1,y1); end.

program oltiburchak; uses graphabc;

var x1,y1,x2,x3,y2,y3,x4,y4,x5,y5,x6,y6:integer;

begin

x1:=trunc(320+cos(pi/3)*100);

y1:=trunc(200+sin(pi/3)*100);

x2:=trunc(320+cos(2*pi/3)*100);

y2:=trunc(200+sin(2*pi/3)*100);

x3:=trunc(320+cos(pi)*100);

y3:=trunc(200+sin(pi)*100);

x4:=trunc(320+cos(4*pi/3)*100);

y4:=trunc(200+sin(4*pi/3)*100);

x5:=trunc(320+cos(5*pi/3)*100);

y5:=trunc(200+sin(5*pi/3)*100);

x6:=trunc(320+cos(6*pi/3)*100);

y6:=trunc(200+sin(6*pi/3)*100);

setpenwidth(5); setpencolor(clblue);

line(x1,y1,x2,y2);line(x2,y2,x3,y3);

line(x3,y3,x4,y4);line(x5,y5,x4,y4);

line(x5,y5,x6,y6);line(x6,y6,x1,y1); end.

Ko’rib turganingizdek, yozgan dasturlarimizda ko’pburchakning tomonlari ortgan sari dasturimizda yoziladigan kodlar ko’payib bormoqda.

Shuning uchun bularni umumlashtirib, bitta dasturga birlashtiramiz. Ushbu dasturda ko’pburchakning uchlarini belgilash uchun massivdan foydalanamiz.

uses crt,graphabc; var i,n:integer;

x,y:array[1..100] of integer; begin

setpenwidth(5); setpencolor(clblue);

write('ko`pburchak necha burchakli bo`lsin?: ');

read(n); floodfill(1,1,claqua);

for i:=1 to n do begin

x[i]:=trunc(320+cos(2*i*pi/n)*100);

y[i]:=trunc(200+sin(2*i*pi/n)*100); end;

for i:=1 to n-1 do begin

line(x[i],y[i],x[i+1],y[i+1]); end;

line(x[n],y[n],x[1],y[1]); end.

E’tiboringiz uchun RAHMAT!

E’tiboringiz uchun RAHMAT!


5/28/20

Yaxshi kayfiyat hamisha hamrohingiz bo‘lsin!
Download 1.69 Mb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2020
ma'muriyatiga murojaat qiling