coin :: Int -> Int -> Int -> Int -> Int
dollar :: Int -> Int -> Int -> Int -> Int
sen :: Int -> Int -> Int -> Int -> Int
coin q d n p = (q * 25) + (d * 10) + (n * 5) + (p * 1)
dollar q d n p = (coin q d n p) `div` 100
sen q d n p = (coin q d n p) `mod` 100
假设(dollar q d n p)
为6,(sen q d n p)
为27。
如何在Haskell中为输出写入"6 dollar and 27 sen"
?
我可以用Python完成,
# [Input]
dollar = 2 * 3
sen = 3 * 9
print(dollar, " dollar and ", sen, "sen")
# [Output]
# 6 dollar and 27 sen
然后,如何在Haskell中编写它,以便输出可以相同?