element value
equal to
zero, then test
each card drawn
to be sure
it isn't
zero.
Now
that
is really simple!
We
will
now, a step at a
time,
write a
program
which will
draw,
at
random,
all 52
cards
numbered
from
1
through
52,
and print
the
card numbers
on the screen
as they are
drawn.
No card will be drawn
more
than
once.
When all cards
have
been drawn,
it will print
"END
OF DECK."
You
do a step first, then
check
against
my example. Then
change
yours
to match
mine
—
otherwise
we
might
not
end up at
the
same place
at the
same time.
Step
1
:
Spin up all 52 cards
into
an array.
30 FOR
C=l
TO
52jREAD
ACO:NEXT
C
50 DATA
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
55
DATA
21,22,23,24,25,26,27,28,29,30,31,32,33,34,35
60 DATA
36,37,38,39,40,41,42,43.44,45,46,47,48,49,50,51,52
At this point, all
you can tell when
RUNning
is that it is
taking some
processing time since
the
READY doesn't
come back right
away.
1
Shhhh! I
know
there's an
easier way
to progiaift
tftis;sp«eiai case;
tot ft
doesn't teach
what's nee4#&
Step
2:
Draw
52
cards
at
random, printing their
values.
90 FOR N
=
1 TO
52
1010 V
=
RND{52)
110 PRINT A(
V)
;
120
NEXT N
m
129