linkedin facebook linkedin facebook nod32

PascalABC da grafiklarga doir misollar

Muallif: Faxriddinov Sh.

Qo`shilgan sana: 2015-01-21

PascalABC da grafiklarga doir misollar

program grafik10_1;
//TOPSHIRISH.-1)grafik darcha yasang 2)uni ekranning (x,y) nuqtasidan boshlab
//joylashtiring 3)darcha kengligi w va balandligi h gab teng qilib o'rnating
//4)darcha sarlavhasi nomini m o'zgaruvchi qiymatiga teng qilib o'rnating
//x=100; y=200; w=50; h=175; m=’ Mustaqil grafik dastur’;
uses graphABC;  //Grafik modulni kiritamiz
begin
setwindowSize(300,400);
 //grafik darcha o'lchamlari kiritdik
SetWindowPos(250,275);
 //grafik darcha joriy o'rni
SetWindowCaption('Mustaqil grafik dastur')
//grafik darcha sarlavhasi kiritdik
end.

program grafik10_2;
//ekranga (x,y) pozitsiyadan boshlab eni w balandligi h ga teng bo'lgan grafik
//dartcha chiqaring.Bu amalni n marta m millisekund interval bilan takrorlang.
//x=200, y=100, w=200, h=100, dx=dy=dw=dh=10, n=40, m=333.
uses crt,graphABC;//Grafik modulni kiritdik
var i:integer;
begin
SetWindowCaption('2-grafik dastur');
//grafik darcha sarlavhasini kiritdik
for i:=0 to 40 do   //takrorlanishlar soni
begin
setwindowSize(200+i*10,100+i*10);
//grafik darcha o'lchamlari
SetWindowPos(200+i*10,100+i*10);
//grafik darcha o'rni
delay(333);    //takrorlanish vaqti tanaffus
end;  //Bunda grafik darcha kompilyatsiya davomida
harakatlanib turadi
end.

program grafik10_3;
//ekranga ixtiyoriy o'lchamli,ixtiyoriy pozitsiyada joylashgan grafik
//darchani har 1000 millisekundda chiqaring va o'zingiz mustaqil ixtiyoriy vaqt
//kirita oladigan dastur tuzing
uses crt,graphABC;//Grafik modulni kiritib oldik
var i:integer;
begin
SetWindowCaption('3-grafik dastur');
//grafik darcha sarlavhasi kiritdik
while true do
begin
setwindowSize(random(screenwidth),random(screenheight));
//grafik darcha o'lchamlarini kiritib oldik
SetWindowPos(random(screenwidth-windowwidth-5),
random(screenheight-windowheight-100));
//grafik darcha o'rnini ham kiritdik
delay(1000);
end;
end.

program grafik10_4;
//ekranga tasodifiy o'lchamli,tasodifiy pozitsiyada joylashgan,tasodifiy
//tanlangan fon rangiga ega grafik darchani xar 1000 millisekundda chiqaradi.Bunda
//barcha grafik darchalar to'laligicha ekranga joylashsin
uses crt,graphABC;//Grafik modulni kiritdik
var i:integer;
begin
SetWindowCaption('4-grafik dastur');
//grafik darcha sarlavhasi kiritdik
while true do
begin
setwindowSize(random(screenwidth-5),
random(screenheight-50));
//grafik darcha o'lchamlari kiritdik
SetWindowPos(random(screenwidth-windowwidth),random(screenheight-windowheight-
50));
//grafik darcha o'rnini kiritdik
floodfill(4,4,random(256*256*256));
delay(1000);//Bunda grafik darcha turli xil ranglarda ekranning har xil tomonlariga
//va har xil vaziyat va o'lchamda chiqariladi
end;
end.

 

program grafik10_5;
  //quyidagi topshiriqni 4-topshiriqni o'lchamdagi to'g'ri to'rtburchak
  //chizish orqali bajarish dasturini tuzing
uses crt,graphABC;//Grafik modulni kiritdik
var i:integer;
begin
SetWindowCaption('5-grafik dastur');
//grafik darcha sarlavhasi
while true do
begin
setwindowSize(random(screenwidth),
random(screenheight));
//grafik darcha o'lchamlarini kiritdik
SetWindowPos(random(screenwidth-windowwidth),random(screenheight-windowheight));
//grafik darcha o'rnini kiritdik
setbrushcolor(random(256*256*256));
fillrect(0,0,windowwidth,windowheight);
delay(1000);
end;
end.

program grafik10_6;
//ekranga eng katta o'lchamli garfik darcha chiqaring.Unga tasodifiy joylashgan
//tasodifiy tanlangan o'lcham va rangga to'g'ri to'rtburchakni ketma-ket dastur
//darchasi yopilguncha qadar chiqariladigan dastur tuzing
uses crt,graphABC;//Grafik modulni kiritdik
var x0,x1,y0,y1:integer;
begin
SetWindowCaption('6-grafik dastur');
//grafik darcha sarlavhasini kiritdik
setwindowSize(screenwidth,screenheight);
//grafik darcha o'lchamlarini kiritdik
SetWindowPos(0,0);
//grafik darcha o'rnini kiritdik
while true do
begin
setbrushcolor(random(256*256*256));
x0:=random(screenwidth);
y0:=random(screenheight);
x1:=random(screenwidth);
y1:=random(screenheight);
fillrect(X0,Y0,X1,Y1);
delay(1);//kompilyatsiya jarayonida har xil rangdagi har xil o'lchamli to'rtburchaklar
//takrorlanib almashinib turadi
end;
end.

program grafik10_7;
//ekranga eng katta o'lchamli grafik darcha chiqaring.Unga tasodifiy joylashgan,
//tasodifiy tanlangan rangga ega piksellarni ketma-ket,dastur darchasi yopilguncha
//qadar chiqaradigan dastur tuzing
uses graphABC;
var x0,y0,color0:integer;
begin
SetWindowCaption('7-grafik dastur');
 //Grafik darchani kiritdik
setwindowSize(screenwidth,screenheight);
SetWindowPos(0,0);
while true do
begin
color0:=random(256*256*256);
x0:=random(screenwidth);
y0:=random(screenheight);
setpixel(X0,Y0,color0);
end;//Bunda darcha butun ekranni qoplaydi va unda piksellar paydo bo'ib
//ko'paya boradi

end.

program grafik10_8;
//ekranga eng katta o'lchamli grafik darcha chiqaring.Undagi har bir pikselni
//tasodifiy tanlangan rangga ketma-ket dastur darchasi yopilguncha qadar chiqaradigan dastur tuzing
uses graphABC;
var x0,y0,color0:integer;
begin
SetWindowCaption('8-grafik dastur');
setwindowSize(screenwidth,screenheight);
SetWindowPos(0,0);
while true do
for x0:=0 to windowwidth-1 do
for y0:=0 to windowheight-1 do
begin
color0:=random(256*256*256);
setpixel(X0,Y0,color0);
end;//Grafik darchada chapdan piksellar bilan to'lgan qator davom etadi

end.

program grafik10_9;
  //ekranga eng katta o'lchamli grafik darcha chiqaring.Piksellarning rangini
  //ketma-ket 0 dan 256*256*256–1=16 777 215 gacha o'zgartirib ekranga ketma-ket
  //chiqaradi
uses graphABC;
var i,x0,y0,color0:integer;
begin
SetWindowCaption('9-grafik dastur');
setwindowSize(screenwidth,screenheight);
SetWindowPos(0,0);
for i:=0 to 256*256*256 do
begin
y0:=i mod Windowheight;
x0:=(i div Windowheight) mod Windowwidth;
setpixel(X0,Y0,i);
end;

end.

program grafik10_10;
//ekranga x1 o'lchamli grafik darcha chiqaring.Grafik darchaning chegara tomonlarining
//har birini i/(n-i) nisbatda bo'luvchi nuqtalarni topib ularning i ning har bir qiymati
//uchun kesmalar bilan birlashtirib chiqaring
uses graphABC;
const
n=100;
l=600;
m=600;
var a,b: integer;
i,j:integer;
begin
setwindowsize(m,l);
for i:=1 to n-1 do
begin
setpencolor(random(256*256*256));
a:=round(l/n*i);
b:=round(m/n*i);
line(0,a,m-b,0);
line(m,a,m-b,l);
line(m,a,b,0);
line(0,l-a,m-b,l);
end;
end.

program grafik10_11;
//ekran o'rtasiga 2RX2R o'lchamli grafik darchani chiqaring.Unga R radiusli
//aylana chizing.Aylanaga ichki chizilgan n burchak yasang.Uning barcha dioganallarini
//chizing R=275  n=30
uses crt,graphABC;
const
n=30;
R=275;
var
i,j:integer;
x,y: array [0..n] of integer;
begin
SetWindowCaption('11-grafik dastur');
setwindowSize(2*r,2*r);
centerWindow;
setpencolor($0000ff);
clearwindow;
textout(3,3,inttostr(n));
circle(r,r,r);
for i:=1 to n do
begin
x[i]:=round(r+r*cos(2*pi/n*i));
y[i]:=round(r+r*sin(2*pi/n*i));
end;
for i:=1 to n-1 do
for j:=i+1 to n do
line(x[i],y[i],x[j],y[j]); 

end.

program grafik10_12;
// ekranga grafik darcha chiqaring.Uning vertikar va gorizontal tomonlarini
//teng bo'laklarga bo'lib hosil bo'lgan nuqtalarni bir-biri bilan tutashtirib chiqing
uses graphABC;
const
k=12;
n=8;
l=700;m=1000;
var x,y:array[0..2*(n+k)] of integer;
i,j:integer;
begin
setwindowsize(m,l);
for i:=0 to n-1 do
begin
x[i]:=0;y[i]:=round((l/n)*i);
x[k+n+i]:=m;y[k+n+i]:=round((l/n)*i);
end;
for i:=0 to k-1 do
begin
y[n+i]:=0;x[n+i]:=round((m/k)*i);
y[n+n+k+i]:=l;x[n+n+k+i]:=round((m/k)*i);
end;
x[n]:=m;y[n]:=l;
setpencolor($0000ff);
for i:=0 to 2*(n+k) do
for j:=i to 2*(n+k) do
line(x[i],y[i],x[j],y[j])
end.

program grafik10_13;
//ichma-ich joylashgan to'g'ri to'rtburchaklarni chizish bilan tasvir hosil qiling
uses graphABC;
const
lm=0.13;
n=21;
l=600;m=600;
var a,b,c,d:array[0..1,0..1] of integer;
i,j:integer;
procedure init;
begin
setwindowsize(2*m,2*l);
a[0,0]:=0;a[0,1]:=0;
b[0,0]:=0;b[0,1]:=l div 2;
c[0,0]:=m div 2;c[0,1]:=l div 2;
d[0,0]:=m div 2;d[0,1]:=0;
setpenwidth(3);
end;
function newP(z1,z2:integer):integer;
begin
newp:=round(lm*z1+(1-lm)*z2);
end;
procedure newrect;
begin
a[1,0]:=newp(a[0,0],b[0,0]);
a[1,1]:=newp(a[0,1],b[0,1]); b[1,0]:=newp(b[0,0],c[0,0]);
b[1,1]:=newp(b[0,1],c[0,1]); c[1,0]:=newp(c[0,0],d[0,0]);
c[1,1]:=newp(c[0,1],d[0,1]); d[1,0]:=newp(d[0,0],a[0,0]);
d[1,1]:=newp(d[0,1],a[0,1]); a[0,0]:=a[1,0];a[0,1]:=a[1,1];
b[0,0]:=b[1,0];b[0,1]:=b[1,1]; c[0,0]:=c[1,0];c[0,1]:=c[1,1];
d[0,0]:=d[1,0];d[0,1]:=d[1,1]; end;
procedure drawl(x1,y1,x2,y2:integer);
begin
line(m div 2 -x1,l div 2 -y1,m div 2 -x2,l div 2 -y2);
line(m div 2 +x1,l div 2 -y1,m div 2 +x2,l div 2 -y2);
line(m div 2 -x1,l div 2 +y1,m div 2 -x2,l div 2 +y2);
line(m div 2 +x1,l div 2 +y1,m div 2 +x2,l div 2 +y2); end;
procedure drawpicture;   begin
setpencolor(i*100000);
drawl(a[0,0],a[0,1],b[0,0],b[0,1]);
drawl(b[0,0],b[0,1],c[0,0],c[0,1]);
drawl(c[0,0],c[0,1],d[0,0],d[0,1]);
drawl(a[0,0],a[0,1],d[0,0],d[0,1]);
floodfill(m div 4 ,l div 4,i*100000);
floodfill(3*m div 4 ,l div 4,i*100000);
floodfill(m div 4 ,3*l div 4,i*100000);
floodfill(3*m div 4 ,3*l div 4,i*100000);
end;   begin    init;
for i:=0 to n-1 do   begin
drawpicture;    newrect;

end;  

end.

program grafik10_14;
  //shaxmat taxtasiga 8 ta bir-birini ura olmaydigan farzinlarni joylashtirish
  //dasturini tuzung
uses crt,graphABC;
var x,y:integer;
s,sf,i,j:integer;
f:array[1..8] of integer;
function shart(i_sh:integer):integer;
var j_sh,s_sh:integer;
begin
s_sh:=1;
for j_sh:=1 to i_sh-1 do
if (f[j_sh]=f[i_sh]) or (abs(f[j_sh]-f[i_sh])=abs(j_sh-i_sh)) then
begin s_sh:=0;break end;
shart:=S_SH;
end;
procedure init_sh;
begin
clearwindow;
setwindowsize(400,400);
centerwindow;
floodfill(100,100,0);
for x:=0 to 7 do
for y:=0 to 7 do
if (x+y) mod 2=0 then
fillrect(x*50,y*50,50+x*50,50+50*y)
end;
procedure show_f;
begin
init_sh;setwindowcaption(inttostr(sf));
setfontsize(30);
for i:=1 to 8 do
textout(f[i]*50-40,(i-1)*50,'O');
delay(5000);
end;
procedure check_f;
var i1,i2, i3,i4,i5,i6,i7,i8:integer;
begin
init_sh;
sf:=0;
for i1:=1 to 8 do
begin f[1]:=i1;
for i2:=1 to 8 do
begin f[2]:=i2; if shart(2)=0 then continue;
for i3:=1 to 8 do
begin f[3]:=i3; if shart(3)=0 then continue;
for i4:=1 to 8 do
begin f[4]:=i4; if shart(4)=0 then continue;
for i5:=1 to 8 do
begin f[5]:=i5; if shart(5)=0 then continue;
for i6:=1 to 8 do
begin f[6]:=i6; if shart(6)=0 then continue;
for i7:=1 to 8 do
begin f[7]:=i7; if shart(7)=0 then continue;
for i8:=1 to 8 do
begin f[8]:=i8; if shart(8)=1 then begin sf:=sf+1;show_f end;
end;end;end;end;end;end;end;end;
writeln(sf);
end;
begin
check_f
end.

2157 marta o`qildi.

Parol:
Eslab qolish.


Ro`yhatdan o`tish

testing

+998915878681

Siz o`z maxsulotingizni 3D reklama ko`rinishda bo`lishini xohlaysizmi? Unda xamkorlik qilamiz.

3D Reklama


Рейтинг@Mail.ru
Рейтинг@Mail.ru

Besucherzahler
счетчик посещений