3-dimensional array is an array that has three indexes. To understand the concept of 3-dimensional array, see the picture below.
To declare 3-dimensional array that can hold 24 character, we can us this statement :
Type
TwoDimensionalArray = array[1..2, 1..3, 1..4] of char;
Var
TheData : TwoDimensionalArray;
Or you can use this statement :
Var
TheData : array[1..2, 1..3, 1..4] of char;
To access an element in 3-dimensional array use this syntax :
ArrayVariableName[ArrayIndex1, ArrayIndex2, ArrayIndex3];
Example :
TheData[1,3,4] := ‘A’;
Writeln(TheData[1,3,4]);
Readln(TheData[1,3,4]);
Example :
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
i, j, k : integer;
Thedata : array[1..2, 1..3, 1..2] of char;
begin
TheData[1,1,1] := 'A';
TheData[1,1,2] := 'B';
TheData[1,2,1] := 'C';
TheData[1,2,2] := 'D';
TheData[1,3,1] := 'E';
TheData[1,3,2] := 'F';
TheData[2,1,1] := 'G';
TheData[2,1,2] := 'H';
TheData[2,2,1] := 'I';
TheData[2,2,2] := 'J';
TheData[2,3,1] := 'K';
TheData[2,3,2] := 'L';
for i := 1 to 2 do
begin
for j := 1 to 3 do
begin
for k := 1 to 2 do writeln(TheData[i,j,k]);
end;
end;
readln;
end.
You can download the complete code here.
sip deh Mas, saya pelajari dulu...
ReplyDeletewah gile, code apaan nih sob mumuet dah lihatnya
ReplyDeleteaq masih blogger pemula, ngutak ngatik kode html blog aja masih bingung apa lagi code2 ginian, hebat kamu sob
ReplyDeletes The best and a lot of secret drop-shipping suppliers in the world which will provide your products globally available for you directly to your customers doors. Also get the best drop-shipping manufacturer on your organization.
Delete