berikut saya berikan contoh program akses array 3d
program AksesArray 3D;
uses crt;
const
xMaks = 2;
yMaks = 2;
zMaks = 2;
type
Array 3D = array [1....xMaks, 1....yMaks, 1....zMaks] of integer;
Var
A = Array3D;
I,j,k : integer ;
X : integer;
Begin
Clrscr ;
{mengisikan nilai kedalam array A}
X = 1;
for i : = 1 to xMaks do begin
for j : = 1 to yMaks do begin
for k : = 1 to zMaks do begin
A[i,j,k] : = x;
inc (x) ;
end ;
end ;
end ;
{untuk indeks pengulangan }
{menampilkan isi yang terdapat dalam array A}
for i : = to xMaks do begin
for j : = 1to yMaks do begin
write (‘A[‘,i,’,’,j,’,’,k,’] = ‘, A[i , j , k],’ ‘ ) ;
end;
end;
writeln ;
end ;
readln ;
end.
Referensi : Buku Array 3D
0 komentar:
Posting Komentar