for
loop
is inclusive, while the upper limit is exclusive.
The step, if not specified, is one.
function f(i,n) { if (i < n) { println(i); f(i+1,n); } }
function f(i,n) { if (i < n) { println(i); f(i*3,n); } }
function f(i,n) { if (i < n) { f(i*sqrt(n),n); println(i); } }
function f(i,j,n) { if (i < n) { if (j < n) f(i,j+1,n); else f(i+1,i+1,n); } println(i,j); }
function f(i,j,n) { if (i < n) { if (j < i) f(i,j+1,n); else f(i+1,0,i+1); } println(i,j); }
function f(i,j,n) { if (i < n) { if (j < n) f(i,j+1,n); else f(i*2,0,n); } println(i,j); }
function f(i,j,n) { if (i < n) { if (j < n) f(i,j+1,n); else f(i*2,i*2,n); } println(i,j); }
function f(i,j,n) { if (i < n) { if (j < n) f(i,j*2,n); else f(i+1,1,n); } println(i,j); }
function f(n) { if (n > 0) { f(n/2); for (var i from 0 until n) println(n); } }
for (i from 0 until n by 1) for (j from 0 until i by 1) println(i,j);
i = 1; while (i < n) { for (j from 0 until n by 1) println(i,j); i = i * 2; }
i = 1; while (i < n) { for (j from 0 until i by 1) println(i,j); i = i * 2; }
for (i from 0 until n) { j = 1; while (j < n) { println(i,j); j = j * 2; } }
for (i from 0 until n by 1) println(i);
i = 1; while (i < n) { println(i); i = i * 2; }
i = 1; while (i < n) { println(i); i = i * sqrt(n); }
i = 1; while (i < n) { println(i); i = i * 2; } for (j from 0 until n by 2) println(j);
for (i from 0 until n by 1) println(i); for (j from 0 until n by 1) println(j);
for (i from 0 until n by 2) println(i); j = 1; while (j < n) { println(j); j = j * 2; }
for (i from 0 until n by 1) println(i);
i = 1; while (i < n) { println(i); i = i * sqrt(n); }
i = 1; while (i < n) { println(i); i = i * 2; }
for (i from 0 until n by 1) println(i); for (j from 0 until n by 1) println(j);
i = 1; while (i < n) { println(i); i = i * 2; } for (j from 0 until n by 2) println(j);
for (i from 0 until n by 2) println(i); j = 1; while (j < n) { println(j); j = j * 2; }
for (i from 0 until n by 1) for (j from 0 until i by 1) println(i,j);
i = 1; while (i < n) { for (j from 0 until i by 1) println(i,j); i = i * 2; }
for (i from 0 until n) { j = 1; while (j < n) { println(i,j); j = j * 2; } }
i = 1; while (i < n) { for (j from 0 until n by 1) println(i,j); i = i * 2; }
function f(i,j,n) { if (i < n) { if (j < n) f(i,j+1,n); else f(i+1,i+1,n); } println(i,j); }
function f(i,j,n) { if (i < n) { if (j < i) f(i,j+1,n); else f(i+1,0,i+1); } println(i,j); }
function f(i,j,n) { if (i < n) { if (j < n) f(i,j+1,n); else f(i*2,0,n); } println(i,j); }
function f(i,j,n) { if (i < n) { if (j < n) f(i,j+1,n); else f(i*2,i*2,n); } println(i,j); }
function f(i,j,n) { if (i < n) { if (j < n) f(i,j*2,n); else f(i+1,1,n); } println(i,j); }
function f(x,n) { if (x > 0) { f(x/2,n); for (var i from 0 until n) println(n); } }
function f(i,n) { if (i < n) { f(i+1,n); println(i); } }
function f(i,n) { if (i < n) { f(i*2,n); println(i); } }
function f(i,n) { if (i < n) { f(i*sqrt(n),n); println(i); } }
function f(i,n) { if (i < n) { f(i+sqrt(n),n); println(i); } }
min = 0; for (i from 0 until array.length) if (array[i] < min) min = array[i];
max = array[0] for (i from 0 to array.length) if (array[i] > max) max = array[i]
True
if the value of item is present in the unsorted,
non-empty array.
function find(array,item) { found = False; for (i from 0 until array.length) if (array[i] == item) found = True; return found; }
False
if the value of item is missing in the unsorted,
non-empty array.
function find(array,item) { found = True; for (i from 0 unitl array.length) if (array[i] != item) found = False; return found; }
for
loop
is inclusive, while the upper limit is exclusive.
The step, if not specified, is one.
v = 0; for (i from 0 until array.length) if (array[i] < v) v = array[i];
v = array[0]; for (i from 0 until array.length) if (array[i] < v) v = array[i];
v = array[0]; for (i from 0 until array.length) if (array[i] > v) v = array[i];
v = array[0]; for (i from 0 until array.length) if (array[i] > v) v = array[i];
function find(array,item) { var i; var found = False; for (i from 0 until array.length) if (array[i] == item) found = True; return found; }
function find(array,item) { var i; for (i from 0 until array.length) if (array[i] == item) return False; return True; }
function find(array,item) { var i; var found = True; for (i from 0 until array.length) if (array[i] != item) found = False; return found; }
function find(array,item) { var i; for (i from 0 until array.length) if (array[i] == item) return True; return False; }
for (i from j until s-2) array[i] = array[i+1]; array[i] = newElement; --- for (i from s-2 until j) array[i+1] = array[i]; array[i] = newElement;
for (i from j until s-2) array[i+1] = array[i]; array[i] = newElement; --- for (i from s-2 until j) array[i] = array[i+1]; array[i] = newElement;
f = (f - 1 + c) % c;
f -= 1; f == 0? c - 1 : f;
f -= 1; f = f < 0? c - 1 : f;
f = f == 0? c - 1 : f - 1;
if (f == 0) f = c - 1; else f = f - 1;
i == c/2 || j == c/2
i + j == c
i == c/2-1 && j == c/2-1
i == c/2-1 || j == c/2-1
i + j == c-2
i == c/2 && j == c/2
s.push(readEquationToken()); s.push(readEquationToken()); while (moreEquationTokens()) { t = readEquationToken(); if (isNumber(t)) s.push(t); else /* t must be an operator */ { operandB = s.pop(); operandA = s.pop(); result = performOperation(t,operandA,operandB); s.push(result); } }
8 2 3 ^ / 2 3 * + 5 1 * -
are read in the order given,
what are the top two values in s immediately after the result of
the first multiplication is pushed?
[2,4,5,10,11,12,13,15,21]
[2,10,11,21,12,13,4,5,15]
[2,10,4,11,13,5,15,21,12]
[21,11,12,10,13,2,5,4,15]
a[n-1]
a[1]
a[2]
a[1]
and
a[2]
[5,21,8,15,25,3,9]
?