zoukankan      html  css  js  c++  java
  • hackerrank--- challenges/fp-update-list

    纯属为了练习haskell, 竟然贴代码都没办法高亮。

    challenges/fp-update-list

    Update the values of a list with their absolute values. The input and output portions will be handled automatically during grading. You only need to write a function with the recommended method signature.

    Input Format 
    There are N integers, each on a new line. These are the N elements of the input array.

    Output Format 
    N integers each on a new line; these are the absolute values of the input list, in that order.

    Sample Input

    2
    -4
    3
    -1
    23
    -4
    -54
    

    Sample Output

    2
    4
    3
    1
    23
    4
    54

    Accpeted Code:

    1 -- Enter your code here. Read input from STDIN. Print output to STDOUT
    2 
    3 f arr = [if x >= 0 then x else -x | x <- arr] -- Complete this function here
    4 
    5 -- This section handles the Input/Output and can be used as it is. Do not modify it.
    6 main = do
    7    inputdata <- getContents
    8    mapM_ putStrLn $ map show $ f $ map (read :: String -> Int) $ lines inputdata
  • 相关阅读:
    Hibernate之二级缓存
    Hibernate之HQL
    Hibernate 一对多自关联 多对多
    hibernate关联关系(一对多)
    Hibernate之主键生成策略
    Hibernate01
    struts的图片上传
    HashMap和HashTable本质性的区别
    集合03
    集合
  • 原文地址:https://www.cnblogs.com/Stomach-ache/p/3794952.html
Copyright © 2011-2022 走看看