From e90dfd68161f50882572c3d4d29caea17118c600 Mon Sep 17 00:00:00 2001 From: Arity-T Date: Tue, 19 Nov 2024 14:53:23 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=B2=D0=BE=D0=B4=20=D1=81=D0=BC=D0=B5?= =?UTF-8?q?=D1=89=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B8=20=D0=BA=D0=BE=D0=BB-?= =?UTF-8?q?=D0=B2=D0=B0=20=D0=B1=D0=B8=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab3/app/Main.hs | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/lab3/app/Main.hs b/lab3/app/Main.hs index eb574f9..4f1807b 100644 --- a/lab3/app/Main.hs +++ b/lab3/app/Main.hs @@ -1,28 +1,31 @@ module Main (main) where +import Text.Read (readMaybe) import Codec.Picture import qualified Data.Vector.Unboxed as VU import Lib -caesarShift :: Int -caesarShift = 66 - -bitsPerByte :: Int -bitsPerByte = 1 - -sourceTextPath :: String -sourceTextPath = "resources/biography.txt" -sourceImagePath :: String -sourceImagePath = "resources/david.bmp" -encodedImagePath :: String -encodedImagePath = "tmp/david_" ++ show caesarShift ++ ".bmp" -decodedTextPath :: String -decodedTextPath = "tmp/biography.txt" - main :: IO () main = do - putStrLn $ "Чтение текста из файла \"" ++ sourceTextPath ++ "\"" + putStrLn "Введите значение сдвига для шифра Цезаря:" + inputCaesarShift <- getLine + let caesarShift = case readMaybe inputCaesarShift of + Just value -> value + Nothing -> error "Ожидалось целое число!" + + putStrLn "Введите количество бит для кодирования:" + inputBitsPerByte <- getLine + let bitsPerByte = case readMaybe inputBitsPerByte of + Just value -> value + Nothing -> error "Ожидалось целое число!" + + let sourceTextPath = "resources/biography.txt" + let sourceImagePath = "resources/david.bmp" + let encodedImagePath = "tmp/david_" ++ show caesarShift ++ ".bmp" + let decodedTextPath = "tmp/biography.txt" + + putStrLn $ "\nЧтение текста из файла \"" ++ sourceTextPath ++ "\"" inputText <- readFile sourceTextPath putStrLn $ "10 символов текста: \"" ++ take 10 inputText ++ "\""