From 828ce0a5c5880a34ca2fa0b34e7aa15104b34af5 Mon Sep 17 00:00:00 2001 From: davidon-top Date: Tue, 25 Feb 2025 09:25:49 +0100 Subject: [PATCH] 29 --- ulohyfs/src/u28.fs | 35 +++++++++++++---------------------- ulohyfs/src/u29.fs | 30 ++++++++++++++++++++++++++++++ ulohyfs/ulohyfs.fsproj | 1 + 3 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 ulohyfs/src/u29.fs diff --git a/ulohyfs/src/u28.fs b/ulohyfs/src/u28.fs index a23f5f8..36a9811 100644 --- a/ulohyfs/src/u28.fs +++ b/ulohyfs/src/u28.fs @@ -1,4 +1,4 @@ -module UlohyFs.u28 +module UlohyFs.u29 open System.IO open System.Text.RegularExpressions @@ -6,25 +6,16 @@ open System.Text.Unicode open UlohyFs.Attributes open System -let (./.) l r = $"{l}{Path.PathSeparator}{r}" +let napoje = [| 20; 55; 45; 95; 150; 105; 100; 45 |] - -let getHobit = - Environment.GetFolderPath(Environment.SpecialFolder.Desktop) ./. "maturita" ./. "ZADANIE č.19" ./. "hobit.txt" - |> fun x -> if File.Exists x then Some(x) else None - |> function - | Some(v) -> File.ReadAllText v - | None -> - printfn "Nepodarilo sa najst hobit.txt zadaj cestu k hobit.txt" - let inp = Console.ReadLine() - File.ReadAllText inp - -[] -let uloha28() = - let h = getHobit - let mutable spaces = 0 - h - |> String.iter (fun c -> if c = ' ' then spaces <- spaces + 1) - printfn "medzery: %d" spaces - h - |> printfn "%s" \ No newline at end of file +[] +let uloha29() = + printfn "napoje:" + napoje |> Array.iteri (fun i x -> printfn $"{i + 1}. cena: {x}") + let inp = Console.ReadLine().Trim() |> int + let mutable cena = napoje[inp - 1] + while not (cena <= 0) do + printfn "vhod mincu, este treba %d" cena + let minca = Console.ReadLine().Trim() |> int + cena <- cena - minca + printfn "vydavok: %d" (Math.Abs cena) \ No newline at end of file diff --git a/ulohyfs/src/u29.fs b/ulohyfs/src/u29.fs new file mode 100644 index 0000000..a23f5f8 --- /dev/null +++ b/ulohyfs/src/u29.fs @@ -0,0 +1,30 @@ +module UlohyFs.u28 + +open System.IO +open System.Text.RegularExpressions +open System.Text.Unicode +open UlohyFs.Attributes +open System + +let (./.) l r = $"{l}{Path.PathSeparator}{r}" + + +let getHobit = + Environment.GetFolderPath(Environment.SpecialFolder.Desktop) ./. "maturita" ./. "ZADANIE č.19" ./. "hobit.txt" + |> fun x -> if File.Exists x then Some(x) else None + |> function + | Some(v) -> File.ReadAllText v + | None -> + printfn "Nepodarilo sa najst hobit.txt zadaj cestu k hobit.txt" + let inp = Console.ReadLine() + File.ReadAllText inp + +[] +let uloha28() = + let h = getHobit + let mutable spaces = 0 + h + |> String.iter (fun c -> if c = ' ' then spaces <- spaces + 1) + printfn "medzery: %d" spaces + h + |> printfn "%s" \ No newline at end of file diff --git a/ulohyfs/ulohyfs.fsproj b/ulohyfs/ulohyfs.fsproj index 1c77b94..8f61548 100644 --- a/ulohyfs/ulohyfs.fsproj +++ b/ulohyfs/ulohyfs.fsproj @@ -17,6 +17,7 @@ +