Einzelnen Beitrag anzeigen

Kas Ob.

Registriert seit: 3. Sep 2023
347 Beiträge
 
#14

AW: Arraygrösse und Stack Overflow

  Alt 21. Feb 2024, 18:45
I would use something like this
Code:
type
  TMatri = array of array of Integer;
  TMatrixArr = array of TMatri;

var
  M: TMatrixArr;
  i, j, k: Integer;

const
  DIM1 = 3;
  DIM2 = 4;
  DIM3 = 5;

begin
  SetLength(M, DIM1);
  for I := Low(M) to High(M) do      // or // for i := 0 to DIM1-1 do
  begin
    SetLength(M[i], DIM2, DIM3);
    for j := 0 to Pred(DIM2) do      // or // for j := 0 to DIM2-1 do
      for k := 0 to Pred(DIM3) do    // or // for k := 0 to DIM3-1 do
        M[i][j, k] := Abs(k - j);
  end;
I think accessing such nested data with M[i][j, k] easier to read and write.
2024-02-21-19_44_05-project5-delphi-xe8-project5.dproj-%5Bstopped%5D-%5Bbuilt%5D.png
Kas
  Mit Zitat antworten Zitat