Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
36
Task/Loops-Break/XBasic/loops-break.basic
Normal file
36
Task/Loops-Break/XBasic/loops-break.basic
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
PROGRAM "loopbreak"
|
||||
|
||||
IMPORT "xst" ' for XstGetSystemTime
|
||||
|
||||
DECLARE FUNCTION Entry()
|
||||
|
||||
' Pseudo-random number generator
|
||||
' Based on the rand, srand functions from Kernighan & Ritchie's book
|
||||
' 'The C Programming Language'
|
||||
DECLARE FUNCTION Rand()
|
||||
DECLARE FUNCTION SRand(seed%%)
|
||||
|
||||
FUNCTION Entry()
|
||||
XstGetSystemTime (@msec)
|
||||
SRand(INT(msec) MOD 32768)
|
||||
DO
|
||||
a%% = Rand() MOD 20
|
||||
PRINT FORMAT$("##", a%%);
|
||||
IF a%% = 10 THEN EXIT DO
|
||||
b%% = Rand() MOD 20
|
||||
PRINT FORMAT$(" ##", b%%)
|
||||
LOOP
|
||||
PRINT
|
||||
END FUNCTION
|
||||
|
||||
' Return pseudo-random integer on 0..32767
|
||||
FUNCTION Rand()
|
||||
#next&& = #next&& * 1103515245 + 12345
|
||||
END FUNCTION USHORT(#next&& / 65536) MOD 32768
|
||||
|
||||
' Set seed for Rand()
|
||||
FUNCTION SRand(seed%%)
|
||||
#next&& = seed%%
|
||||
END FUNCTION
|
||||
|
||||
END PROGRAM
|
||||
Loading…
Add table
Add a link
Reference in a new issue