TRS-80
MODEL
III
Array/Matrix
Manipulation Subroutines
To
use this subroutine,
your main program must supply values for two
variables N
1
(number of rows)
and N2 (number of columns). Within the
subroutine, you
can
assign values
to
the
elements in the
array
row by row by answering
the INPUT
statement.
IB FOR ROW
=
1 TO Nl
20 FOR COL
=
1
TO IM2
30 PRINT "ENTER DATA FOR
";
ROW 5
":";
COL
40 INPUT A C
ROW » COL
)
50 NEXT COL
60 NEXT ROW
70 RETURN
To
use
this
subroutine, your main program must supply values for three variables
Nl (size
of
dim
#
1 ),
N2
(size of dim
#2)
and N3 (size of dim
#3).
Within the
subroutine,
you can assign values to each element of the array using READ
and
DATA statements. You must supply I x
J
x K elements in the following order: row
by
row
for K
=
1
, row by row for K
=
2,
row by row for K
=
3
,
and so on
for each value
ofN3.
"A STMTS.
400 REM
REQUIRES DA
410 FOR K
=
1
TO
N3
420 FOR I
=
1 TO Nl
430
FOR
J
=
1 TO N2
440 READ
AU»J»K)
450
NEXT
J» I»
K
460
RETURN
Main program
supplies values for variables Nl
,
N2, N3
.
The
subroutine prints
the
array.
560 FOR
K
=
1 TO N3
570 FOR I
=
1 TO
Nl
580 FOR
J
=
1
TO
N2
590 PRINT A(
I,
J,K>»
600 NEXT
J: PRINT
610 NEXT
is
PRINT
620 NEXT
Ks
PRINT
630 RETURN
176