Family Day update
This commit is contained in:
parent
aac6731f2c
commit
9ad63ea473
2442 changed files with 39761 additions and 8255 deletions
|
|
@ -1,29 +1,29 @@
|
|||
GUESSNUM
|
||||
; get a random number between 1 and 100
|
||||
set target = ($random(100) + 1) ; $r(100) gives 0-99
|
||||
|
||||
; loop until correct
|
||||
set tries = 0
|
||||
for {
|
||||
write !,"Guess the integer between 1 and 100: "
|
||||
read "",guess ; gets input following write
|
||||
|
||||
; validate input
|
||||
if (guess?.N) && (guess > 0) && (guess < 101) {
|
||||
; increment attempts
|
||||
set tries = tries + 1
|
||||
|
||||
; evaluate the guess
|
||||
set resp = $select(guess < target:"too low.",guess > target:"too high.",1:"correct!")
|
||||
|
||||
; display result, conditionally exit loop
|
||||
write !,"Your guess was "_resp
|
||||
quit:resp="correct!"
|
||||
}
|
||||
else {
|
||||
write !,"Please enter an integer between 1 and 100."
|
||||
}
|
||||
} ; guess loop
|
||||
|
||||
write !!,"You guessed the number in "_tries_" attempts."
|
||||
quit
|
||||
; get a random number between 1 and 100
|
||||
set target = ($random(100) + 1) ; $r(100) gives 0-99
|
||||
|
||||
; loop until correct
|
||||
set tries = 0
|
||||
for {
|
||||
write !,"Guess the integer between 1 and 100: "
|
||||
read "",guess ; gets input following write
|
||||
|
||||
; validate input
|
||||
if (guess?.N) && (guess > 0) && (guess < 101) {
|
||||
; increment attempts
|
||||
set tries = tries + 1
|
||||
|
||||
; evaluate the guess
|
||||
set resp = $select(guess < target:"too low.",guess > target:"too high.",1:"correct!")
|
||||
|
||||
; display result, conditionally exit loop
|
||||
write !,"Your guess was "_resp
|
||||
quit:resp="correct!"
|
||||
}
|
||||
else {
|
||||
write !,"Please enter an integer between 1 and 100."
|
||||
}
|
||||
} ; guess loop
|
||||
|
||||
write !!,"You guessed the number in "_tries_" attempts."
|
||||
quit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue