小编use*_*145的帖子

用户输入内容时的Haskell ..总结txt文件中的数字

假设用户输入= 6000并且input.txt内的数字是= 5000.总和将是11000.屏幕上显示的数字和存储在文件中的值将被覆盖为11000.请帮助我,谢谢

import System.IO

menu :: IO ()
menu = do

handle <- openFile "input.txt" ReadMode  
          contents <- hGetContents handle 
      putStr contents
      hClose handle
      contents <- readFile "input.txt"
      print . sum . read $ contents
      putStr("\nThe amount of money that you want to deposit : ")
      y<-getLine
Run Code Online (Sandbox Code Playgroud)

haskell haskell-platform

0
推荐指数
1
解决办法
537
查看次数

标签 统计

haskell ×1

haskell-platform ×1