
15.12.2011, 17:46
|
Прохожий
|
|
Регистрация: 15.12.2011
Сообщения: 10
Репутация: 10
|
|
я включил опцию goEditing, и изменил код....но теперь выдаёт ошибку EConvertError при нажатие на Button1
Код:
unit Unit_masiv;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
edt1: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
A : array of array of integer;
m, n: integer;
imax, jmax, imin, jmin: integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Var
i, j: integer;
begin
SetLength(A,n,m);
for j:=0 to m-1 do
for i:=0 to n-1 do
begin
A[i,j]:=StrToInt(StringGrid1.Cells[j,i]);
end;
imax:=0;
jmax:=0;
For i:=0 to High(A) do
For j:=0 to High(A) do
if A[i,j] > A[imax,jmax] then begin
imax:=i;
jmax:=j;
end;
edt1.Text:='Skaitlis: '+IntToStr(A[imax,jmax])+' Indeks: ['+IntToStr(imax+1)+','+IntToStr(jmax+1)+']';
end;
procedure TForm1.Button2Click(Sender: TObject);
Var
i, j: integer;
begin
if (Edit1.Text<>'') and (Edit2.Text<>'') then
begin
n:=StrToInt(Edit1.Text);
m:=StrToInt(Edit2.Text);
StringGrid1.RowCount:=n+1;
StringGrid1.ColCount:=m+1;
with StringGrid1 do
begin
for i:=1 to RowCount do
begin
Cells[i,0]:=IntToStr(i);
end;
for j:=1 to ColCount do
begin
Cells[0,j]:=IntToStr(j);
end;
end;
end
else edt1.Text:='Error!!! Ievadit dimensiju!';
end;
end.
|