Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
36
Task/Loops-Nested/Jsish/loops-nested.jsish
Normal file
36
Task/Loops-Nested/Jsish/loops-nested.jsish
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* Loops/Nested in Jsish */
|
||||
Math.srand(0);
|
||||
var nrows = Math.floor(Math.random() * 4) + 4;
|
||||
var ncols = Math.floor(Math.random() * 6) + 6;
|
||||
|
||||
var matrix = new Array(nrows).fill(0).map(function(v, i, a):array { return new Array(ncols).fill(0); } );
|
||||
|
||||
var i,j;
|
||||
for (i = 0; i < nrows; i++) for (j = 0; j < ncols; j++) matrix[i][j] = Math.floor(Math.random() * 20) + 1;
|
||||
|
||||
/* Labelled break point */
|
||||
outer_loop:
|
||||
for (i in matrix) {
|
||||
printf("row %d:", i);
|
||||
for (j in matrix[i]) {
|
||||
printf(" %d", matrix[i][j]);
|
||||
if (matrix[i][j] == 20) {
|
||||
printf("\n");
|
||||
break outer_loop;
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
puts(matrix);
|
||||
|
||||
/*
|
||||
=!EXPECTSTART!=
|
||||
row 0: 2 18 12 16 14 8 18 15 9 8
|
||||
row 1: 15 6 8 16 17 12 15 2 10 3
|
||||
row 2: 11 8 12 20
|
||||
[ [ 2, 18, 12, 16, 14, 8, 18, 15, 9, 8 ],
|
||||
[ 15, 6, 8, 16, 17, 12, 15, 2, 10, 3 ],
|
||||
[ 11, 8, 12, 20, 18, 4, 6, 6, 19, 9 ],
|
||||
[ 16, 3, 2, 19, 1, 4, 8, 4, 11, 18 ] ]
|
||||
=!EXPECTEND!=
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue