Взял из Dev-Cpp
Код
declare sub Start ()
declare sub GetResults ()
dim shared as integer i, j, life, maxrand
dim shared as byte c
' program start
print "** Jackpot game **"
print "The goal of this game is to guess a number. You will be ask to type"
print "a number (you have 5 guess)"
print "Jackpot will then tell you if this number is too big of too small compared to the secret number to find"
print
Start()
end
sub Start ()
i = 0
j = 0
life = 0
maxrand = 6
print "Select difficulty mode:" ' the user has to select a difficulty level
print "1 : Easy (0-15)"
print "2 : Medium (0-30)"
print "3 : Difficult (0-50)"
print "or type another key to quit"
c = 30
input ">",c ' read the user's choice
print
select case c
case 1 : maxrand = 15 ' the random number will be between 0 and maxrand
case 2 : maxrand = 30
case 3 : maxrand = 50
case else: end 0
end select
life = 5 ' number of lifes of the player
randomize timer
j = rnd * maxrand ' j get a random value between 0 and maxrand
GetResults()
end sub
sub GetResults ()
if (life <= 0) then
' if player has no more life then he lose
print "You lose !"
print
Start()
end if
print "Type a number:"
input ">",i ' read user's number
if ((i>maxrand) orelse (i<0)) then ' if the user number isn't correct, restart
print "Error : Number not between 0 and ";maxrand
GetResults()
end if
if (i = j) then
print "YOU WIN !" ' the user found the secret number
print
Start()
ElseIf (i>j) then
print "Too BIG"
life = life - 1 ' -1 to the user's "life"
print "Number of remaining life: ";life
print
GetResults()
ElseIf (i<j) then
print "Too SMALL"
life = life - 1
print "Number of remaining life: "; life
print
GetResults()
end if
end sub