Advertisement
vencinachev

GuessTheNumber

Nov 18th, 2020
1,077
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. main :: IO()
  2. main = do
  3.     putStr "Enter number to guess: "
  4.     line1 <- getLine
  5.     let a = read line1 :: Int
  6.     guessTheNum a
  7.  
  8. guessTheNum :: Int -> IO()
  9. guessTheNum num = do
  10.     input <- getLine
  11.     let n = read input :: Int
  12.     if num == n then
  13.         putStrLn "Yes"
  14.     else
  15.         if num > n then
  16.             do
  17.                 putStrLn "UP"
  18.                 guessTheNum num
  19.         else
  20.             do
  21.                 putStrLn "DOWN"
  22.                 guessTheNum num
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement