いろんな言語で宿題ス ..
[2ch|▼Menu]
459:デフォルトの名無しさん
09/07/12 23:52:08
>>457
-- Haskell

import System.Random (getStdRandom, random)
import Control.Monad (replicateM)
import Data.List (maximumBy, minimumBy)
import Data.Function (on)

main = do
rands <- replicateM 100 (getStdRandom random :: IO Int)
let i = zip [1..] rands
putStrLn $ "(index, maximum) = " ++ show (maximumBy (compare `on` snd) i)
putStrLn $ "(index, minimum) = " ++ show (minimumBy (compare `on` snd) i)
putStrLn $ "average = " ++ show (on (/) fromIntegral (sum rands) 100)


次ページ
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

4630日前に更新/314 KB
担当:undef