Масаланинг дасурий таъминоти
Ixtiyoriy kiritish tugmasi:
procedure TForm1.Button2Click(Sender: TObject);
var
i,j:integer;
begin
for i:=1 to StringGrid1.ColCount-1 do
for j:=1 to 2 do
StringGrid1.Cells[i,j]:=inttostr(random(30));
end;
Hisoblash tugmasi:
procedure TForm1.Button1Click(Sender: TObject);
var
b:boolean;
s1,s2,s3,s4,s5:string;
i,i1,j,k,m,n,min:integer;
a:array[1..2,1..100] of integer;
st:set of byte;
f,l:integer;
ss,sb:array[1..100] of string;
begin
Label3.Caption:='';
Label4.Caption:='';
Label7.Caption:='';
f:=1;
l:=1;
st:=[0];
for i:=1 to 2 do
for j:=1 to StringGrid1.ColCount-1 do
a[i,j]:=StrToInt(StringGrid1.Cells[j,i]);
b:=true;
m:=StringGrid1.ColCount-1;
s1:='';
s2:='';
s3:='';
for i:=1 to m do
begin
k:=1;
while ((k in st)) do
begin
inc(k);
if k=m then break;
end;
n:=k;
if b then min:=a[1,k] else min:=a[2,k];
for j:=1 to m do
begin
if b then
if (a[1,j]begin
min:=a[1,j];
n:=j;
end;
if not b then
if (a[2,j]begin
min:=a[2,j];
n:=j;
end;
end;
if b then
begin
sb[l]:=inttostr(min);
inc(l);
s1:=s1+inttostr(min)+', ';
s4:=s4+'P'+inttostr(n)+', ';
end
else
begin
ss[f]:=inttostr(min);
inc(f);
s2:=s2+inttostr(min)+', ';
s5:=s5+' ,'+inttostr(n)+'P';
end;
st:=st+[n];
b:=not b;
end;
Label3.Caption:=s1;
Label4.Caption:=s2;
for i:=f-1 downto 1 do
s3:=s3+ss[i]+', ';
Label7.Caption:=Label7.Caption+s4;
for i:=Length(s5) downto 1 do
Label7.Caption:=Label7.Caption+s5[i];
end;
Do'stlaringiz bilan baham: |