Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
40
Task/Loops-Nested/S-BASIC/loops-nested-1.basic
Normal file
40
Task/Loops-Nested/S-BASIC/loops-nested-1.basic
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
$constant ROWS = 10
|
||||
$constant COLUMNS = 10
|
||||
$constant MAXVAL = 20
|
||||
|
||||
var i, j = integer
|
||||
dim integer table(ROWS, COLUMNS)
|
||||
|
||||
rem - populate table using nested FOR..NEXT loops
|
||||
|
||||
for i=1 to ROWS
|
||||
for j=1 to COLUMNS
|
||||
table(i, j) = int(rnd(1) * MAXVAL) + 1
|
||||
next j
|
||||
next i
|
||||
|
||||
rem - show results using nested WHILE..DO loops
|
||||
|
||||
i = 1
|
||||
while i <= ROWS do
|
||||
begin
|
||||
j = 1
|
||||
while j <= COLUMNS do
|
||||
begin
|
||||
print using "## "; table(i, j);
|
||||
if table(i, j) = MAXVAL then goto 0done
|
||||
j = j + 1
|
||||
end
|
||||
print
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
comment
|
||||
Although S-BASIC allows alphanumeric line numbers as the target
|
||||
of a GOTO or GOSUB statement, the first "digit" must in fact be
|
||||
a number, as shown here.
|
||||
end
|
||||
|
||||
0done if i > ROWS then print "target value"; MAXVAL; " not found!"
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue