Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
64
Task/Playing-cards/QuickBASIC/playing-cards.basic
Normal file
64
Task/Playing-cards/QuickBASIC/playing-cards.basic
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
DECLARE SUB setInitialValues (deck() AS STRING * 2)
|
||||
DECLARE SUB shuffle (deck() AS STRING * 2)
|
||||
DECLARE SUB showDeck (deck() AS STRING * 2)
|
||||
DECLARE FUNCTION deal$ (deck() AS STRING * 2)
|
||||
|
||||
DATA "AS", "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "TS", "JS", "QS", "KS"
|
||||
DATA "AH", "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "TH", "JH", "QH", "KH"
|
||||
DATA "AC", "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "TC", "JC", "QC", "KC"
|
||||
DATA "AD", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "TD", "JD", "QD", "KD"
|
||||
|
||||
RANDOMIZE TIMER
|
||||
|
||||
REDIM cards(51) AS STRING * 2
|
||||
REDIM cards2(51) AS STRING * 2
|
||||
|
||||
setInitialValues cards()
|
||||
setInitialValues cards2()
|
||||
shuffle cards()
|
||||
PRINT "Dealt: "; deal$(cards())
|
||||
PRINT "Dealt: "; deal$(cards())
|
||||
PRINT "Dealt: "; deal$(cards())
|
||||
PRINT "Dealt: "; deal$(cards())
|
||||
showDeck cards()
|
||||
showDeck cards2()
|
||||
|
||||
FUNCTION deal$ (deck() AS STRING * 2)
|
||||
'technically dealing from the BOTTOM of the deck... whatever
|
||||
DIM c AS STRING * 2
|
||||
c = deck(UBOUND(deck))
|
||||
REDIM PRESERVE deck(LBOUND(deck) TO UBOUND(deck) - 1) AS STRING * 2
|
||||
deal$ = c
|
||||
END FUNCTION
|
||||
|
||||
SUB setInitialValues (deck() AS STRING * 2)
|
||||
DIM L0 AS INTEGER
|
||||
|
||||
RESTORE
|
||||
FOR L0 = 0 TO 51
|
||||
READ deck(L0)
|
||||
NEXT
|
||||
END SUB
|
||||
|
||||
SUB showDeck (deck() AS STRING * 2)
|
||||
FOR L% = LBOUND(deck) TO UBOUND(deck)
|
||||
PRINT deck(L%); " ";
|
||||
NEXT
|
||||
PRINT
|
||||
END SUB
|
||||
|
||||
SUB shuffle (deck() AS STRING * 2)
|
||||
DIM w AS INTEGER
|
||||
DIM shuffled(51) AS STRING * 2
|
||||
DIM L0 AS INTEGER
|
||||
|
||||
FOR L0 = 51 TO 0 STEP -1
|
||||
w = INT(RND * (L0 + 1))
|
||||
shuffled(L0) = deck(w)
|
||||
IF w <> L0 THEN deck(w) = deck(L0)
|
||||
NEXT
|
||||
|
||||
FOR L0 = 0 TO 51
|
||||
deck(L0) = shuffled(L0)
|
||||
NEXT
|
||||
END SUB
|
||||
Loading…
Add table
Add a link
Reference in a new issue