mattsan #6835(2008/07/25 22:30 GMT) [ Haskell ] Rating0/0=0.00
きっともっと綺麗な書き方があると思うのですが、挑戦の意味を込めて投稿です。
1 2 3 4 5 6 7 8 9 10 11 12 13
import System.Random import Text.Printf direction = [(1, 0), (0, 1), (-1, 0), (0, -1)] printPoint :: (Int, (Int, Int)) -> IO () printPoint (n, (x, y)) = printf "%4d%4d%4d¥n" n x y addPair (x1, y1) (x2, y2) = (x1 + x2, y1 + y2) main = do gen <- getStdGen mapM_ printPoint $ take 10 $ zip [1..] $ scanl addPair (0, 0) $ map (\x -> direction !! (mod x 4)) $ randoms gen
Rating0/0=0.00-0+
1 reply [ reply ]
mattsan
#6835()
[
Haskell
]
Rating0/0=0.00
きっともっと綺麗な書き方があると思うのですが、挑戦の意味を込めて投稿です。
Rating0/0=0.00-0+
1 reply [ reply ]