Показать сообщение отдельно
  #6  
Старый 21.12.2010, 20:08
stil stil вне форума
Новичок
 
Регистрация: 24.11.2010
Сообщения: 91
Репутация: 41
По умолчанию вот на форму

Код:
{размерность массива}
procedure TForm1.Button1Click(Sender: TObject);
begin
StringGrid1.ColCount:=StrToInt(edit1.text);
StringGrid1.RowCount:=StrToInt(edit1.text);
end;
{перестановка}
procedure TForm1.Button2Click(Sender: TObject);
var i,j,i1,j1,n: integer;
    b: array of real;
    min:real;
begin
n:=StringGrid1.ColCount;
setLength(b,n);
min:=abs(StrToFloat(StringGrid1.cells[0,0]));
for i:=0 to StringGrid1.ColCount-1 do
  for j:=0 to StringGrid1.RowCount-1 do begin
    if min>abs(StrToFloat(StringGrid1.cells[i,j])) then begin
      min:=abs(StrToFloat(StringGrid1.cells[i,j]));
      i1:=i;
      j1:=j;
    end;
  end;
for i:=0 to n-1 do begin
  b[i]:=StrToFloat(StringGrid1.cells[i1,i]);
  StringGrid1.cells[i1,i]:=StringGrid1.cells[n-1,i];
  StringGrid1.cells[n-1,i]:=FloatToStr(b[i]);
end;
for i:=0 to n-1 do begin
  b[i]:=StrToFloat(StringGrid1.cells[i,j1]);
  StringGrid1.cells[i,j1]:=StringGrid1.cells[i,n-1];
  StringGrid1.cells[i,n-1]:=FloatToStr(b[i]);
end;
end;
У StringGrid1 св-во Options->doEditing->true
Ответить с цитированием