ABC#011 A.来月は何月?
Haskellで挑戦。
問題
与えられた月の次の月を返す。
考え方
N+1。ただし、N=12のときは1になることに注意。
書いたコード
import Control.Applicative import Control.Monad nextMonth n = if n < 12 then n + 1 else 1 main = do n <- readLn print $ nextMonth n
Haskellで挑戦。
与えられた月の次の月を返す。
N+1。ただし、N=12のときは1になることに注意。
import Control.Applicative import Control.Monad nextMonth n = if n < 12 then n + 1 else 1 main = do n <- readLn print $ nextMonth n