On (18 Apr 98) David Williams wrote to All...
Hi David,
DW> I've noticed a lot of code posted here recently that doesn't look too
DW> great to me. In particular, a lot of people seem to use loops that
DW> generate RNDs over and over again until some criterion is satisfied.
DW> This is (almost) *never* necessary!
far be it from me to even hint at the possibility of a criticism...
but...
DW> 130 DIM A%(49)
doesn't this set all elements of the array to zero?
DW> 180 ' start of shuffling loop
erm, doesn't this use a 'loop' of some kind :-)
DW> 200 ' shuffle random 6 numbers into first 6 positions
um, what for?
DW> 210 FOR X% = 1 TO 6
DW> 220 Y% = INT((48) * RND) + 1
ok, how about using your loop as modified above then
IF A%(Y%) 0 then 220
A%(Y%)=1
NEXT
the numbers will be different and there's no need to sort them as you
simply read each element of the array from 1 upwards and if the element
value is non-zero you print the element number.
Success
Peter
--- PPoint 1.88
---------------
* Origin: Peter Points at last! (2:254/60.26)
|