Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
40
Task/21-game/PureBasic/21-game.basic
Normal file
40
Task/21-game/PureBasic/21-game.basic
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
If OpenConsole()
|
||||
PLAYER.i = 1
|
||||
COMP.i = 0
|
||||
|
||||
sum.i = 0
|
||||
total.i = 0
|
||||
turn.i = Random(1) + 0.5
|
||||
Dim precomp.i(3)
|
||||
precomp(0) = 1
|
||||
precomp(1) = 1
|
||||
precomp(2) = 3
|
||||
precomp(3) = 2
|
||||
|
||||
While sum < 21
|
||||
turn = 1 - turn
|
||||
PrintN("The sum is " + Str(sum))
|
||||
If turn = PLAYER
|
||||
PrintN("It is your turn.")
|
||||
While total < 1 Or total > 3 Or total + sum > 21
|
||||
Print("How many would you like to total? ")
|
||||
total = Val(Input())
|
||||
Wend
|
||||
Else
|
||||
PrintN("It is the computer's turn.")
|
||||
total = precomp(sum % 4)
|
||||
PrintN("The computer totals " + Str(total) + ".")
|
||||
EndIf
|
||||
PrintN("")
|
||||
sum + total
|
||||
total = 0
|
||||
Wend
|
||||
|
||||
If turn = PLAYER
|
||||
PrintN("Congratulations. You win.")
|
||||
Else
|
||||
PrintN("Bad luck. The computer wins.")
|
||||
EndIf
|
||||
|
||||
Input()
|
||||
EndIf
|
||||
Loading…
Add table
Add a link
Reference in a new issue