Create a two-dimensional array at runtime: Difference between revisions

Added Oz.
(alloca for stack allocation.)
(Added Oz.)
Line 454:
print_float array.(0).(0); print_newline ();;</lang>
 
=={{header|Oz}}==
Oz does not have multi-dimensional arrays. But we can create an array of arrays (similarly to most examples on this page):
<lang oz>declare
%% Read width and height from stdin
class TextFile from Open.file Open.text end
StdIn = {New TextFile init(name:stdin)}
Width = {String.toInt {StdIn getS($)}}
Height = {String.toInt {StdIn getS($)}}
%% create array
Arr = {Array.new 1 Width unit}
in
for X in 1..Width do
Arr.X := {Array.new 1 Height 0}
end
%% set and read element
Arr.1.1 := 42
{Show Arr.1.1}</lang>
=={{header|Pascal}}==
{{works with|GNU Pascal|20060325, based on gcc-3.4.4}}
Anonymous user