
29.05.2011, 20:31
|
Прохожий
|
|
Регистрация: 19.05.2011
Сообщения: 5
Репутация: 10
|
|
DJ PhoeniX, спасибо!
Спасибо! Подправил: Уже считает но всё равно не корректно...
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
StringGrid1: TStringGrid;
Button1: TButton;
Button2: TButton;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
procedure Edit1Change(Sender: TObject);
procedure Edit2Change(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
n,m,j,i,k,min,max:integer;
r:array[1..20,1..20] of integer;
implementation
{$R *.dfm}
procedure TForm1.Edit1Change(Sender: TObject);//Ввод количества строк массива
var
i:integer;
begin
n:=strtoint(edit1.Text);
stringgrid1.RowCount:=n+1;
for i:=1 to n do
stringgrid1.Cells[0,i]:=inttostr(i);
end;
procedure TForm1.Edit2Change(Sender: TObject);//Ввод количества столбцов массива и вывода номера столбца в Stringgrid1.Cells[i,0]
var
j:integer;
begin
m:=strtoint(edit2.Text);
stringgrid1.ColCount:=m+1;
for j:=1 to m do
stringgrid1.Cells[j,0]:=inttostr(j);
For i:=1 to StringGrid1.ColCount-1 do
For j:=1 to StringGrid1.RowCount-1 do
begin
StringGrid1.Cells[j,i]:=ШтеToStr(r[i,j]);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
j,i,min,max:integer;
begin
min:=r[1,1];
For i:=1 to StringGrid1.RowCount-1 do
For j:=1 to Form1.StringGrid1.ColCount-1 do
begin
r[i,j]:=StrToInt(StringGrid1.Cells[j,i]);
end;
if r[i,j]<min then begin min:=r[i,j];
end;
max:=r[1,1];
For i:=1 to StringGrid1.ColCount-1 do
For j:=1 to StringGrid1.RowCount-1 do
begin
r[i,j]:=StrToInt(StringGrid1.Cells[j,i]);
end;
if r[i,j]>max then begin max:=r[i,j];
end;
Label4.Caption:=IntToStr(min);
Label3.Caption:=IntToStr(max);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
end.
|