
11.12.2009, 00:41
|
Прохожий
|
|
Регистрация: 11.12.2009
Сообщения: 10
Репутация: 10
|
|
вот что у мя получилось! но чето не работает!
Код:
procedure TForm1.Button1Click(Sender: TObject);
var a:array of array of integer;
b:array of array of integer;
p:array of integer;
q:array of integer;
m,n,i,j,h,min,y,z,k,x:integer;
begin
N:=StrToInt(Edit1.text);
M:=StrToInt(edit2.text);
StringGrid1.colcount:=n;
StringGrid1.rowcount:=m;
StringGrid2.colcount:=n;
StringGrid2.rowcount:=m;
for I := 1 to N do
for j := 1 to M do A[i,j]:=random(40);
for I := 1 to N do
for j := 1 to M do StringGrid1.Cells[j-1,i-1]:=IntToStr (a[i,j]);
for I := 1 to N do begin k:=0;
for j := 1 to M do if A[i,j]mod 2 = 1 then k:=k+1;
p[i]:=k; q[i]:=i;
end;
for h := 1 to N - 1 do begin min:=q[h];
x:=h+1;
for i := x to N do if min>p[i] then begin y:=min; min:=p[i]; p[i]:=y;
z:=q[h]; q[h]:=q[i]; q[i]:=z;
end;
end;
for h := 1 to n do
for i := 1 to n do
for j := 1 to m do
B[i,j]:=a[q[h],j];
for i := 1 to n do
for j := 1 to m do
stringgrid2.cells[j-1,i-1]:=IntToStr(B[i,j]);
end;
end.
Admin: Пользуемся тегами!
|