Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,37 @@
|
|||
import Nanoquery.Util
|
||||
|
||||
random = new(Random)
|
||||
inclusive_range = {1, 100}
|
||||
|
||||
print format("Guess my target number that is between %d and %d (inclusive).\n",\
|
||||
inclusive_range[0], inclusive_range[1])
|
||||
target = random.getInt(inclusive_range[1]) + inclusive_range[0]
|
||||
answer = 0
|
||||
i = 0
|
||||
while answer != target
|
||||
i += 1
|
||||
print format("Your guess(%d): ", i)
|
||||
txt = input()
|
||||
|
||||
valid = true
|
||||
try
|
||||
answer = int(txt)
|
||||
catch
|
||||
println format(" I don't understand you input of '%s' ?", txt)
|
||||
value = false
|
||||
end
|
||||
|
||||
if valid
|
||||
if (answer < inclusive_range[0]) or (answer > inclusive_range[1])
|
||||
println " Out of range!"
|
||||
else if answer = target
|
||||
println " Ye-Haw!!"
|
||||
else if answer < target
|
||||
println " Too low."
|
||||
else if answer > target
|
||||
println " Too high."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
println "\nThanks for playing."
|
||||
Loading…
Add table
Add a link
Reference in a new issue