发布网友 发布时间:2022-04-23 09:46
共1个回答
热心网友 时间:2023-10-10 00:06
mole Main where
import IO
import Random
doGuessing num = do
putStrLn "Enter your guess:"
guess <- getLine
let guessNum = read guess
if guessNum < num
then do putStrLn "Too Low!"
doGuessing num
else if guessNum > num
then do putStrLn "Too High!"
doGuessing num
else do putStrLn "Right!"
main = do
hSetBuffering stdin LineBuffering
num <- randomRIO (1::Int, 100)
putStrLn "I'm thinking of a number between 1 and 100"
doGuessing num