From 86d7aab1ec91c067a9820aaa5ef2c22e8cc12ae0 Mon Sep 17 00:00:00 2001 From: Lukasl32 Date: Wed, 23 Oct 2024 09:40:27 +0200 Subject: [PATCH] =?UTF-8?q?#4=20-=20vytvo=C5=99en=C3=AD=20gener=C3=A1toru?= =?UTF-8?q?=20pseudon=C3=A1hodn=C3=BDch=20=C4=8D=C3=ADsel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../004-app4-generator.csproj | 11 ++++ IS-Projekty/004-app4-generator/Program.cs | 56 +++++++++++++++++++ IS-Projekty/CodebaseIS.sln | 6 ++ 3 files changed, 73 insertions(+) create mode 100644 IS-Projekty/004-app4-generator/004-app4-generator.csproj create mode 100644 IS-Projekty/004-app4-generator/Program.cs diff --git a/IS-Projekty/004-app4-generator/004-app4-generator.csproj b/IS-Projekty/004-app4-generator/004-app4-generator.csproj new file mode 100644 index 0000000..3e1ad04 --- /dev/null +++ b/IS-Projekty/004-app4-generator/004-app4-generator.csproj @@ -0,0 +1,11 @@ + + + + Exe + net9.0 + _004_app4_generator + enable + enable + + + diff --git a/IS-Projekty/004-app4-generator/Program.cs b/IS-Projekty/004-app4-generator/Program.cs new file mode 100644 index 0000000..9359b48 --- /dev/null +++ b/IS-Projekty/004-app4-generator/Program.cs @@ -0,0 +1,56 @@ +namespace _004_app4_generator; + +internal class Program +{ + static void Main(string[] args) + { + string repeate = "a"; + bool valid = true; + while (repeate.Equals("a")) + { + Console.Clear(); + Console.WriteLine("********************************"); + Console.WriteLine("******** Lukáš Moravec *********"); + + int count; + int min; + int max; + + Console.Write("Zadejte počet čísel k vygenerování N (celé číslo): "); + while (!int.TryParse(Console.ReadLine(), out count)) + Console.Write("Chybně zadané celé číslo!! \nZadejte znovu: "); + + do + { + if (!valid) + Console.WriteLine("\n!!! Spodní mez musí být menší než horní mez !!!\n"); + + Console.Write("Zadejte dolní mez (celé číslo): "); + while (!int.TryParse(Console.ReadLine(), out min)) + Console.Write("Chybně zadané celé číslo!! \nZadejte znovu: "); + + Console.Write("Zadejte horní mez (celé číslo): "); + while (!int.TryParse(Console.ReadLine(), out max)) + Console.Write("Chybně zadané celé číslo!! \nZadejte znovu: "); + + valid = min < max; + } + while (!valid); + + int[] output = new int[count]; + + Console.WriteLine("Konfigurace generátoru je počet čísel: {0}, horní mez: {1}, dolní mez {2}", count, max, min); + + Random random = new Random(); + + Console.WriteLine("\nNáhodná čísla: "); + for (int i = 0; i < output.Length; i++) + { + output[i] = random.Next(min, max+1); + Console.Write(" {0} ", output[i]); + } + + Console.ReadKey(); + } + } +} diff --git a/IS-Projekty/CodebaseIS.sln b/IS-Projekty/CodebaseIS.sln index a74d37a..bafe5ec 100644 --- a/IS-Projekty/CodebaseIS.sln +++ b/IS-Projekty/CodebaseIS.sln @@ -18,6 +18,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "003a-app3a-obdelnik", "003a EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "003b-app3b-pravouhly-trojuhelnik", "003b-app3b-pravouhly-trojuhelnik\003b-app3b-pravouhly-trojuhelnik.csproj", "{B10FA3D9-091F-4EF3-92C0-10470F82E3AB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "004-app4-generator", "004-app4-generator\004-app4-generator.csproj", "{709955AC-6F80-4B98-B4D9-C081B4EE1775}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -44,6 +46,10 @@ Global {B10FA3D9-091F-4EF3-92C0-10470F82E3AB}.Debug|Any CPU.Build.0 = Debug|Any CPU {B10FA3D9-091F-4EF3-92C0-10470F82E3AB}.Release|Any CPU.ActiveCfg = Release|Any CPU {B10FA3D9-091F-4EF3-92C0-10470F82E3AB}.Release|Any CPU.Build.0 = Release|Any CPU + {709955AC-6F80-4B98-B4D9-C081B4EE1775}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {709955AC-6F80-4B98-B4D9-C081B4EE1775}.Debug|Any CPU.Build.0 = Debug|Any CPU + {709955AC-6F80-4B98-B4D9-C081B4EE1775}.Release|Any CPU.ActiveCfg = Release|Any CPU + {709955AC-6F80-4B98-B4D9-C081B4EE1775}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE