Тот ещё
Старожил
Регистрация: 14.11.2007
Сообщений: 2,242
|
Наверное от того, что с чем-то подобным уже сталкивался, немного зацепило.
Вот чего насочинял
Код:
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids;
type
TVect1 = array [0..1 ] of Integer;
TVect2 = array [0..2 ] of Integer;
TVect3 = array [0..3 ] of Integer;
TVect4 = array [0..4 ] of Integer;
TVect5 = array [0..5 ] of Integer;
TVect6 = array [0..6 ] of Integer;
TVect7 = array [0..7 ] of Integer;
TVect8 = array [0..8 ] of Integer;
TVect9 = array [0..9 ] of Integer;
TVect10 = array [0..10] of Integer;
TVect11 = array [0..11] of Integer;
TVect12 = array [0..12] of Integer;
TVect13 = array [0..13] of Integer;
TVect14 = array [0..14] of Integer;
TVect15 = array [0..15] of Integer;
TVect16 = array [0..16] of Integer;
TVect17 = array [0..17] of Integer;
TVect18 = array [0..18] of Integer;
TVect19 = array [0..19] of Integer;
TVect20 = array [0..20] of Integer;
TVect = array of Integer;
PVect = ^TVect;
// TArray = array of TVect;
// PArray = ^TArray;
const
_V1: TVect10 = (10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
_V2: TVect13 = (13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 9, 6, 5);
_V3: TVect20 = (20, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
_V4: TVect5 = (5 , 0, 0, 0, 2, 3);
_ARR: array [0..3] of PVect = (@_V1[1], @_V2[1], @_V3[1], @_V4[1]);
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
Math;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
i, j: Integer;
pv: PVect;
v: TVect;
begin
StringGrid1.RowCount := Length (_ARR) + 1;
j := 0;
for i := Low(_ARR) to High(_ARR) do begin
pv := _ARR[i];
PVect (v) := pv;
j := Max (j, Length(v));
end;
StringGrid1.ColCount := j + 1;
for i := 1 to StringGrid1.ColCount-1 do
StringGrid1.Cells[i,0] := IntToStr(i);
for j := 1 to StringGrid1.RowCount-1 do begin
StringGrid1.Cells[0,j] := IntToStr(j);
pv := _ARR[j-1];
PVect (v) := pv;
for i := 1 to Length(v) do
StringGrid1.Cells[i,j] := IntToStr(v[i-1]);
end;
end;
end.
Можно обернуть
Код:
pv := _ARR[i];
PVect (v) := pv;
в инлайн функцию, и будет вообще красота
|