Swap with Arrays |
Smart pascal source code
type TElem = array [0..1] of Integer; { unit1.pas } var a: array of TElem; e: array[0..1] of Integer; Begin a.SetLength(2); a[0, 0] := 1; a[0, 1] := 2; a[1, 0] := 3; a[1, 1] := 4; Writeln(a[0, 0]); // 1 Writeln(a[0, 1]); // 2 Writeln(a[1, 0]); // 3 Writeln(a[1, 1]); // 4 a.Swap(0, 1); WriteLn('-----'); for e in a do begin Writeln(e[0]); // 3 1 Writeln(e[1]); // 4 2