linkedin facebook linkedin facebook nod32

Delphida massivlar bilan ishlash algoritmlarga doir misollar

Muallif: Mengliyev Shoydullo

Qo`shilgan sana: 2014-10-27

Delphida massivlar bilan ishlash algoritmlarga doir misollar

4.1-masala. A(1), A(2)….,A(N) ketma-ketlikda berilgan jadval elementlarini teskari tartibda ekranga chiqaring.

procedure TForm1.Button1Click(Sender: TObject);
begin
N:=StrToInt(Edit1.Text);
StringGrid1.ColCount:=N;
StringGrid2.ColCount:=N;
end;
procedure TForm1.Button2Click(Sender: TObject);
var a,a1,k:real;I:byte;
begin
for I:=0 TO n-2 div 2 DO begin
a:=StrToFloat(StringGrid1.Cells[i,0]);
a1:=StrToFloat(StringGrid1.Cells[n-i-1,0]);
begin k:=a;a:=a1;a1:=k;
StringGrid2.Cells[i,0]:=FloatToStr(a);
StringGrid2.Cells[i+1,0]:=FloatToStr(a1);

end;end;end;

end.

4.2-masala. N ta elementdan tashkil topgan massivning elementlari yig’indisini toping.

procedure TForm1.Button1Click(Sender: TObject);
begin
N:=StrToInt(Edit1.Text);
StringGrid1.ColCount:=N;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
S:=0;
FOR I:=0 TO n-1 DO
S:=S+STRTOFLOAT(StringGrid1.Cells[I,0]);
Edit2.Text:= FloatToStr(S);
end;

end.

4.3-masala. N ta elementdan iborat bir o’lchovli massiv elementalarini kiritng va ularni ekranga chiqaring.
Yechish. Birinchi sikl yordamida massiv elementalarini kiritamiz. Ikkinchi sikl yordamida ularni ekranga chiqaramiz.

procedure TForm1.Button1Click(Sender: TObject);
begin
N:=StrToInt(Edit1.Text);
StringGrid1.ColCount:=N;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Memo1.Clear;
FOR I:=0 TO n-1 DO
memo1.Lines.Add(inttostr(i+1)+'-element '+StringGrid1.Cells[i,0]);
end;

end.

4.4-masala.N ta elementdan iborat bir o’lchovli massaviy elementlarning yig’indisi S va manfiy elementlar soni K ni aniqlang.

Yechish. Birinchi sikl yordamida massiv elementalarini kiritamiz. Ikkinchi sikl yordamida massiv elementalarining yig’indisini hamda manfiy elementlar sonini hisoblaymiz.

procedure TForm1.Button1Click(Sender: TObject);
VAR N:Integer;
begin
N:=StrToInt(Edit1.Text);
StringGrid1.ColCount:=N;
end;
procedure TForm1.Button2Click(Sender: TObject);
var S:REAL;
I,k:INTEGER;
begin
S:=0;k:=0;
FOR I:=0 TO strtoint(Edit1.Text)-1 DO
S:=S+STRTOFLOAT(StringGrid1.Cells[I,0]);
Edit2.Text:= FloatToStr(S);
FOR I:=0 TO strtoint(Edit1.Text)-1 DO
if STRTOFLOAT(StringGrid1.Cells[I,0])<0 then k:=k+1;
Edit3.Text:=inttostr(k);

end;

end.

4.5-masala. N ta elementdan iborat massiv elementlarning o’rnini almashtirib, ularni o’sadigan tartibda joylashtiring.

procedure TForm1.Button1Click(Sender: TObject);
VAR N:Integer;
begin
N:=StrToInt(Edit1.Text);
StringGrid1.ColCount:=N;
end;
procedure TForm1.Button2Click(Sender: TObject);
label 1;
var a,a1,k:real; I:byte;
begin
1:for I:=0 TO strtoint(Edit1.Text)-2 DO begin
a:=StrToFloat(StringGrid1.Cells[i,0]);
a1:=StrToFloat(StringGrid1.Cells[i+1,0]);
if a>a1 then
begin k:=a;a:=a1;a1:=k;
StringGrid1.Cells[i,0]:=FloatToStr(a);
StringGrid1.Cells[i+1,0]:=FloatToStr(a1);
end;end;
FOR I:=0 TO strtoint(Edit1.Text)-2 DO begin
a:=StrToFloat(StringGrid1.Cells[i,0]);
a1:=StrToFloat(StringGrid1.Cells[i+1,0]);
if a>a1 then goto 1;end;

end;

end.

4.6-masala. A(N) massivning eng kichik elementini toping.
Yechish. Massivning birinchi elementini Z bilan belgilab, massiv elementalarini ketma-ket solishtiramiz va ulardan kichigini Z ga tenglaymiz. Eng kichik elementlar sonini k bilan belgilaymiz.

procedure TForm1.Button1Click(Sender: TObject);
VAR N:Integer;
begin
N:=StrToInt(Edit1.Text);
StringGrid1.ColCount:=N;
end;
procedure TForm1.Button2Click(Sender: TObject);
var I:byte;m:real;
begin
m:=strtofloat(StringGrid1.Cells[0,0]);
FOR I:=1 TO strtoint(Edit1.Text)-1 DO
if m>strtofloat(stringGrid1.Cells[I,0]) then
m:=strtofloat(StringGrid1.Cells[i,0]);
Edit2.Text:= FloatToStr(m);

end;end.

4.7-masala. Bir o’lchovli massivning elementlari A(N) berilgan. Absolyut qiymati 7 dan katta bo’lgan massiv elementlari sonini aniqlang.

Yechish. Absolyut qiymati 7 dan katta bo’lmagan elementlar sonini x bilan belgilaymiz.

procedure TForm1.Button1Click(Sender: TObject);
VAR N:Integer;
begin
N:=StrToInt(Edit1.Text);
StringGrid1.ColCount:=N;
end;
procedure TForm1.Button2Click(Sender: TObject);
var I,t:byte;
begin
t:=0;
FOR I:=0 TO strtoint(Edit1.Text)-1 DO
if strtofloat(stringGrid1.Cells[I,0])>7 then t:=t+1;
Edit2.Text:=intToStr(t);

end;end.

4.8-masala. N ta elementdan iborat bir o’lchovli massivning elementlari ichida 7 ga teng element borligini aniqlang.
Yechish. Birinchi sikl yordamida massivn elementlarini kirita boramiz va ularning ichida 7 soni bor yoki yo’qligini aniqlaymiz. Ikkinchi sikl yordamida massivn elementlarini bosib chiqaramiz.

procedure TForm1.Button1Click(Sender: TObject);
VAR N:Integer;
begin
N:=StrToInt(Edit1.Text);
StringGrid1.ColCount:=N;
end;
procedure TForm1.Button2Click(Sender: TObject);
var I,t:byte;
begin t:=0;
FOR I:=0 TO strtoint(Edit1.Text)-1 DO
if strtofloat(stringGrid1.Cells[I,0])=7 then t:=t+1;
if t>0 then Edit2.Text:='bor' else Edit2.Text:='yo`q';

end;end.

4.9-masala. N ta elementdan iborat bir o’lchovli massiv berilgan. Bu massiv elementlarining o’rta arifmetik qiymatidan katta bo’lgan elementlar sonini toping.

Yechish. Massiv elementlarining o’rta arifmetik qiymatini Z, undan katta bo’lgan massiv elementlari sonini k bilan belgilaymiz.

procedure TForm1.Button1Click(Sender: TObject);
VAR N:Integer;
begin
N:=StrToInt(Edit1.Text);
StringGrid1.ColCount:=N;
end;
procedure TForm1.Button2Click(Sender: TObject);
var S:REAL;
I,k:INTEGER;
begin
S:=0;k:=0;
FOR I:=0 TO strtoint(Edit1.Text)-1 DO
S:=S+STRTOFLOAT(StringGrid1.Cells[I,0]);
s:=s/strtoint(Edit1.Text);
FOR I:=0 TO strtoint(Edit1.Text)-1 DO
if STRTOFLOAT(StringGrid1.Cells[I,0])>s then k:=k+1;
Edit2.Text:=inttostr(k);

end;end.

4.10-masala. A(N) jadval elementlari ko’paytmasini toping.

procedure TForm1.Button1Click(Sender: TObject);
VAR N:Integer;
begin
N:=StrToInt(Edit1.Text);
StringGrid1.ColCount:=N;
end;
procedure TForm1.Button2Click(Sender: TObject);
var S:REAL;
I:INTEGER;
begin
S:=1;
FOR I:=0 TO strtoint(Edit1.Text)-1 DO
S:=S*STRTOFLOAT(StringGrid1.Cells[I,0]);
Edit2.Text:= FloatToStr(S);
end;

end.

o`rganish on-line

1455 marta o`qildi.

Foydalanuvchi ismi: botir 102
Qo`shilgan sana: 2014-05-06

juda tshunarli ekan raxmat !

Foydalanuvchi ismi: bektashev botir 102
Qo`shilgan sana: 2014-05-20

juda tshunarli va programaga kirgzlganda effekt beryapti raxmat

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
счетчик посещений