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

Content added Content deleted
m (added ALGOL-M example)
m (fixed formatting glitch on ALGOL-M example)
Line 487: Line 487:
</pre>
</pre>



==={{header|ALGOL-M}}===
=={{header|ALGOL 68}}==
<syntaxhighlight lang="algol68">main:(
print("Input two positive whole numbers separated by space and press newline:");
[read int,read int] INT array;
array[1,1]:=42;
print (array[1,1])
)</syntaxhighlight>

=={{header|ALGOL-M}}==
<syntaxhighlight lang="ALGOL">
<syntaxhighlight lang="ALGOL">
begin
begin
Line 501: Line 510:
begin % we need to start a new block %
begin % we need to start a new block %
integer array test[1:first, 1:second];
integer array test[1:first, 1:second];
integer i, j;
test[1,1] := 99;
write("Stored value at 1,1 =",test[1,1]);
i := first - 1;
j := second - 1;
test[i,j] := 99;
write("Stored value =",test[i,j]);
end; % array is now out of scope %
end; % array is now out of scope %


Line 517: Line 523:
Length of second dimension:
Length of second dimension:
->7
->7
Stored value = 99
Stored value at 1,1 = 99
</pre>
</pre>


=={{header|ALGOL 68}}==
<syntaxhighlight lang="algol68">main:(
print("Input two positive whole numbers separated by space and press newline:");
[read int,read int] INT array;
array[1,1]:=42;
print (array[1,1])
)</syntaxhighlight>


=={{header|ALGOL W}}==
=={{header|ALGOL W}}==