Printing The Contents Of The Array - Epson FX-80 User Manual

Hide thumbs Also See for FX-80:
Table of Contents

Advertisement

Here are the loops:
3fJ FOR J=1 TO RE
4fJ N=N+1
5fJ GOSUB 3fJfJ
6fJ IF N(MAX THEN 4fJ
7fJ N=N-1
BfJ GOSUB 3fJfJ
9fJ IF N)MIN THEN 7fJ
1fJfJ NEXT J: PRINT
The
J
loop will REpeat four times (RE
=
4). It has two sub-loops that
depend on the value of N. Each time through the first loop (lines 40 to
60), N increases by one-to the value of MAX; each second loop (lines
70 to 90), N decreases by one-to the value of MIN. For each value of
N, the program calls subroutine 300. This routine adds more ones and
zeros into the array each time
it
is called. Type:
29fJ STOP
3fJfJ FOR K=fJ TO MAX-N
31fJ FOR L=1 TO N
32fJ C=C+l: A(C)=X
33fJ NEXT L: X=1-X
34fJ NEXT K: PRINT N;: RETURN
Line 320 in the L loop stores the ones and zeros into the array. The end
of line 330 makes X alternate between zero and one.
To see what the array contains at this point, type:
11fJ FOR K=1 TO C: LPRINT A(K);:
NEXT K: LPRINT: LPRINT"C="C
and RUN your growing program for the results shown in Figure 16-2:
1
Ql
1
Ql
1
Ql
Ql
1
1
Ql
Ql
1
1
Ql
Ql
IZ1
1
1
1
Ql
Ql
Ql
1
1
1
1
Ql
0 0 0 1 1 1 1 1 0 0 1 2 1 1 2 1 1 1 1 1 . 0
Ql
Ql
1
1
1
Ql
Ql
Ql
1
1
Ql
Ql
1
1
Ql
Ql
1
Ql
1
Ql
1
IZ1
Ql
1
1
Ql
(')
1
1
Ql
Ql
Ql
1
1
1
Ql
0
0
1
1
1
1
0
0
1 2 1 0 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 1 0 1 2 1 0 1 1 0 1
1 2 ) 1 1 0 0 1 0 1 0 1 0 0 1 1 0 0 1
l Q l 0 Q l l l 1 Q l 0 0 1 1 1 1 0 l ' l 1 Z l 0 1 1 1 1 1 0 0 " 1 Z 1
1
1
1
1
0
Ql
Ql
1
I
I
I2l
"
'"
I
I
Ql
111
1 1 0 0 1 0 1 0 1 0 0 1 1 . 1 Z ! 0 1 1 0 0 0 1 1 1 0 V ' l 0 1
I
I
1
Ql
111
Ql
IZ1
I
1
I
I
I
IZ1
IZl
111
'"
j
1 1 1 1 2 1 0 0 1 1 1 0 0 0 1 1 1 2 1 0 1 1 0 0 1 0 1 0 1 .
c=
245
Figure 16·2. Printing the contents of the array.
185

Advertisement

Table of Contents
loading

Table of Contents