Created
December 19, 2011 03:28
-
-
Save omegatakuma/1495255 to your computer and use it in GitHub Desktop.
パソコン甲子園2010の過去問をHaskellでといてみた.問題番号[3]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sumTo x = (read :: String -> Int) x | |
getInt = do m <- getLine;return (sumTo m) | |
heikin list = (sum list) `div` (length list) | |
-- 条件の関数 | |
joken list = do | |
if (!!) list 0 == 100 || (!!) list 1 == 100 || (!!) list 2 == 100 | |
then "A" | |
else if ((!!) list 0 + (!!) list 1) `div` 2 >= 90 | |
then "A" | |
else if heikin list >= 80 | |
then "A" | |
else if heikin list >= 70 | |
then "B" | |
else if heikin list >=50 && (!!) list 0 >= 80 || (!!) list 1 >= 80 | |
then "B" | |
else "C" | |
-- クラス分けの関数 | |
juq n d = do | |
if n == d | |
then return () | |
else do | |
putStrLn "数学";pm <- getInt | |
putStrLn "英語";pe <- getInt | |
putStrLn "国語";pj <- getInt | |
putStrLn ("この人は"++(show(joken [pm,pe,pj]))++"クラスです") | |
juq n (d+1) | |
-- main | |
main = do | |
putStrLn "生徒の人数は?" | |
n <- getInt | |
juq n 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ちょっと入力方法が違うんですが、そのうち書き直します。