Добавил:
Xer1t
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лаба 9 вар 9 / Unit1
.pas unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
const m=3; n=3;
var x:array[1..m, 1..n] of real;
i,j: byte;
Cod: integer;
LastMax, LastCol, LastRow: real;
procedure TForm1.Button1Click(Sender: TObject);
begin
StringGrid1.RowCount:=n;
StringGrid1.ColCount:=m;
LastMax:=x[i,j];
for i:=1 to n do
begin
for j:=1 to m do
begin
Val(StringGrid1.Cells[i-1,j-1],x[i,j], Cod);
if Cod<>0 then
ShowMessage('Введены некорректные данные');
end;
end;
for i:=1 to n do
begin
for j:=1 to m do
begin
if x[i,j]>LastMax then
begin
LastMax:=x[i,j];
LastCol:=i;
LastRow:=j;
end;
end;
end;
Label1.Caption:=FloatToStr(LastMax)+' является максимальным значением';
Label2.Caption:='Строка: '+FloatToStr(LastRow)+' Столбец: '+FloatToStr(LastCol);
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
const m=3; n=3;
var x:array[1..m, 1..n] of real;
i,j: byte;
Cod: integer;
LastMax, LastCol, LastRow: real;
procedure TForm1.Button1Click(Sender: TObject);
begin
StringGrid1.RowCount:=n;
StringGrid1.ColCount:=m;
LastMax:=x[i,j];
for i:=1 to n do
begin
for j:=1 to m do
begin
Val(StringGrid1.Cells[i-1,j-1],x[i,j], Cod);
if Cod<>0 then
ShowMessage('Введены некорректные данные');
end;
end;
for i:=1 to n do
begin
for j:=1 to m do
begin
if x[i,j]>LastMax then
begin
LastMax:=x[i,j];
LastCol:=i;
LastRow:=j;
end;
end;
end;
Label1.Caption:=FloatToStr(LastMax)+' является максимальным значением';
Label2.Caption:='Строка: '+FloatToStr(LastRow)+' Столбец: '+FloatToStr(LastCol);
end;
end.