Jump to content

Generate random numbers without repeating a value: Difference between revisions

Generate random numbers without repeating a value en QBasic
(Generate random numbers without repeating a value en BASIC256)
(Generate random numbers without repeating a value en QBasic)
Line 74:
 
 
=={{header|BASIC256BASIC}}==
==={{header|BASIC256}}===
{{trans|FreeBASIC}}
<lang BASIC256>arraybase 1
Line 99 ⟶ 100:
print
end subroutine</lang>
 
==={{header|QBASIC}}===
{{trans|FreeBASIC}}
<lang qbasic>DECLARE SUB pRand ()
 
RANDOMIZE TIMER
FOR num = 1 TO 5
pRand
NEXT num
END
 
SUB pRand
DIM randCheck(1 TO 21)
nr = 1
DO
aleat = INT(RND * 20) + 1
IF randCheck(aleat) <> 1 THEN
randCheck(aleat) = 1
PRINT aleat;
END IF
FOR n = 1 TO UBOUND(randCheck)
IF randCheck(nr) = 1 THEN nr = nr + 1
NEXT n
LOOP UNTIL nr = 21
PRINT
END SUB</lang>
 
 
2,169

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.