Anonymous user
Create a two-dimensional array at runtime: Difference between revisions
Create a two-dimensional array at runtime (view source)
Revision as of 22:20, 12 November 2020
, 3 years agoAdded 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
w = readLineFromStdin("Width: ").parseInt()
h = readLineFromStdin("Height: ").parseInt()
s = newSeq[seq[int]](h)▼
# Create the rows.
# Create the columns.
for i in 0 ..< h:
s[i].newSeq(w)
# 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}}==
|