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

No edit summary
Line 254:
 
=={{header|D}}==
<lang d>import std.stdio: writef, writeflnstd.conv, readlnstd.string;
import std.conv: toInt;
import std.string: strip;
 
void main() {
writefwrite("Give me the numer of rows: ");
int nrow = toIntto!int(readln().strip());
 
writefwrite("Give me the numer of columns: ");
int ncol = toIntto!int(readln().strip());
 
auto array = new float[][](nrow, ncol);
array[0][0] = 3.5;
writeflnwriteln("The number at place [0, 0] is ", array[0][0]);
}</lang>
 
Anonymous user