Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
|
|
@ -1,22 +1,21 @@
|
|||
import std.stdio, std.conv, std.string;
|
||||
|
||||
void main() {
|
||||
import std.stdio, std.conv, std.string;
|
||||
int nRow, nCol;
|
||||
|
||||
write("Give me the numer of rows: ");
|
||||
try {
|
||||
nRow = readln().strip().to!int();
|
||||
} catch (StdioException e) {
|
||||
nRow = readln.strip.to!int;
|
||||
} catch (StdioException) {
|
||||
nRow = 3;
|
||||
writeln();
|
||||
writeln;
|
||||
}
|
||||
|
||||
write("Give me the numer of columns: ");
|
||||
try {
|
||||
nCol = to!int(readln().strip());
|
||||
} catch (StdioException e) {
|
||||
nCol = readln.strip.to!int;
|
||||
} catch (StdioException) {
|
||||
nCol = 5;
|
||||
writeln();
|
||||
writeln;
|
||||
}
|
||||
|
||||
auto array = new float[][](nRow, nCol);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
-module( two_dimensional_array ).
|
||||
|
||||
-export( [create/2, get/3, set/4, task/0] ).
|
||||
|
||||
create( X, Y ) -> array:new( [{size, X}, {default, array:new( [{size, Y}] )}] ).
|
||||
|
||||
get( X, Y, Array ) -> array:get( Y, array:get(X, Array) ).
|
||||
|
||||
set( X, Y, Value, Array ) ->
|
||||
Y_array = array:get( X, Array ),
|
||||
New_y_array = array:set( Y, Value, Y_array ),
|
||||
array:set( X, New_y_array, Array ).
|
||||
|
||||
task() ->
|
||||
{ok, [X, Y]} = io:fread( "Input two integers. Space delimited, please: ", "~d ~d" ),
|
||||
Array = create( X, Y ),
|
||||
New_array = set( X - 1, Y - 1, X * Y, Array ),
|
||||
io:fwrite( "In position ~p ~p we have ~p~n", [X - 1, Y - 1, get( X - 1, Y - 1, New_array)] ).
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
printf(true, "in the following terminate every number with semicolon `;'")$
|
||||
n: readonly("Input x-size: ")$
|
||||
m: readonly("Input y-size: ")$
|
||||
a: make_array(fixnum, n, m)$
|
||||
fillarray(a, makelist(i, i, 1, m*n))$
|
||||
|
||||
/* indexing starts from 0 */
|
||||
print(a[0,0]);
|
||||
print(a[n-1,m-1]);
|
||||
Loading…
Add table
Add a link
Reference in a new issue