Delphida massivlar bilan ishlash algoritmlarga doir misollar 1-masala


Download 257.5 Kb.
bet2/7
Sana02.02.2023
Hajmi257.5 Kb.
#1146880
1   2   3   4   5   6   7
Bog'liq
Delphida ishlash algoritmlarga doir misollar

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.

Download 257.5 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7




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