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

Added comments and completed the task.
(Updated code to work with version 1.4 of Nim.)
(Added comments and completed the task.)
Line 1,497:
=={{header|Nim}}==
<lang nim>import strutils, rdstdin
 
let
var
w = readLineFromStdin("Width: ").parseInt()
h = readLineFromStdin("Height: ").parseInt()
s = newSeq[seq[int]](h)
 
# Create the rows.
var s = newSeq[seq[int]](h)
# Create the columns.
for i in 0 ..< h:
s[i].newSeq(w)</lang>
 
# Store a value in an element.
s[0][0] = 5
 
# Retrieve and print it.
echo s[0][0]
 
# The allocated memory is freed by the garbage collector.</lang>
 
=={{header|Objeck}}==
Anonymous user