06 2012 档案

摘要:1.Haskell风格的main = putStr (s ++ show s);s=" main = putStr (s ++ show s);s="--我在想假如把s串放在最前面该怎么写。2.C风格的,利用printf函数import Text.Printfs="import Text.Printf%cs=%c%s%c;main = printf s (13::Int) (34::Int) s (34::Int)";main = printf s (13::Int) (34::Int) s (34::Int) 阅读全文
posted @ 2012-06-19 14:49 eternalwt 阅读(164) 评论(0) 推荐(0)
摘要:--打印直角三角形。import Control.Monadmain n = mapM_ print (map (\x -> replicate x '*') [1..n])--打印等腰三角形,第n行有2n-1个*号。import Control.Monadmain n = mapM_ print (map (\x -> (replicate (n-x) ' ')++(replicate (2*x-1) '*')++(replicate (n-x) ' ')) [1..n]) 阅读全文
posted @ 2012-06-11 17:38 eternalwt 阅读(201) 评论(0) 推荐(0)