Формирую массив случайным образом и нахожу максимальный и минимальный элементы.
Код
StringGrid1.RowCount:=StrToInt(Edit1.Text);
StringGrid1.ColCount:=StrToInt(Edit2.Text);
randomize;
for i:=0 to StringGrid1.ColCount-1 do
for j:=0 to StringGrid1.RowCount-1 do
StringGrid1.Cells[i,j]:=IntToStr(Round(Sin(Random(100))*100));
max:=0;
for j:=0 to StringGrid1.RowCount-1 do
for i:=0 to StringGrid1.ColCount-1 do
if StrToInt(StringGrid1.Cells[i,j])>max then
max:=StrToInt(StringGrid1.Cells[i,j]);
Label5.Caption:=IntToStr(max);
min:=0;
for j:=0 to StringGrid1.RowCount-1 do
for i:=0 to StringGrid1.ColCount-1 do
if StrToInt(StringGrid1.Cells[i,j])<min then
min:=StrToInt(StringGrid1.Cells[i,j]);
Label6.Caption:=IntToStr(min);