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

m
→‎{{header|REXX}}: added DO-END labels, remove superflous blanks. -- ~~~~
m (→‎{{header|REXX}}: added DO-END labels, remove superflous blanks. -- ~~~~)
Line 1,185:
 
=={{header|REXX}}==
<lang rexx>
/*REXX program to allocate/populate/display a two-dimensional array. */
 
<lang rexx>/*REXX program to allocate/populate/display a two-dimensional array. */
call bloat
/*no more array named A. at this point.*/
 
exit
/*-------------------------BLOAT subroutine-----------------------------*/
 
bloat: procedure; say
 
 
bloat: procedure
 
say
say 'Enter two positive integers (a 2-dimensional array will be created).'
say
Line 1,206 ⟶ 1,200:
a.='~' /*default value for all elements so far. */
/*this ensures every element has a value. */
 
do j=1 for n
do k=1 for m
if random()//7==0 then a.j.k=j'_'k /*populate every 7th random*/
end /*k*/
end /*j*/
 
 
do jj=1 for n /*now, display the array to the console. */
_=''
do kk=1 for m
_=_ right(a.jj.kk,4) /*display one row at a time, align the vals*/
end /*kk*/
say _
end /*jj*/
 
/*when the RETURN is executed (from a */
/*PROCEDURE in this case), the array A. is*/
Line 1,234 ⟶ 1,225:
/*The same effect is performed by a DROP. */
drop a.
return</lang>
'''output''' when the following input is entered after the prompt message: <tt> 30 15 </tt>
</lang>
Output when
<br><br>
30 15
<br><br>
is entered after the prompt message.
<pre style="height:30ex;overflow:scroll">
~ 1_2 ~ ~ ~ ~ ~ 1_8 1_9 1_10 1_11 ~ ~ ~ ~