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

Content added Content deleted
m (→‎{{header|Run Basic}}: Language names are case-sensitive and I think lang tag names only take one word)
(Updated D entry)
Line 372: Line 372:


void main() {
void main() {
int nRow, nCol;

write("Give me the numer of rows: ");
write("Give me the numer of rows: ");
try {
int nrow = to!int(readln().strip());
nRow = readln().strip().to!int();
} catch (StdioException e) {
nRow = 3;
writeln();
}


write("Give me the numer of columns: ");
write("Give me the numer of columns: ");
try {
int ncol = to!int(readln().strip());
nCol = to!int(readln().strip());
} catch (StdioException e) {
nCol = 5;
writeln();
}


auto array = new float[][](nrow, ncol);
auto array = new float[][](nRow, nCol);
array[0][0] = 3.5;
array[0][0] = 3.5;
writeln("The number at place [0, 0] is ", array[0][0]);
writeln("The number at place [0, 0] is ", array[0][0]);
}</lang>
}</lang>
{{out}}
<pre>Give me the numer of rows:
Give me the numer of columns:
The number at place [0, 0] is 3.5</pre>


=={{header|Delphi}}==
=={{header|Delphi}}==