diff --git a/LottoLista/LottoLista.sln b/LottoLista/LottoLista.sln new file mode 100644 index 0000000..316b5fa --- /dev/null +++ b/LottoLista/LottoLista.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36429.23 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LottoLista", "LottoLista\LottoLista.csproj", "{36A8D202-B4E8-46B6-9D02-F9DB6F2F0100}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {36A8D202-B4E8-46B6-9D02-F9DB6F2F0100}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {36A8D202-B4E8-46B6-9D02-F9DB6F2F0100}.Debug|Any CPU.Build.0 = Debug|Any CPU + {36A8D202-B4E8-46B6-9D02-F9DB6F2F0100}.Release|Any CPU.ActiveCfg = Release|Any CPU + {36A8D202-B4E8-46B6-9D02-F9DB6F2F0100}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2EC8B3BE-B408-424D-B245-45C545B61608} + EndGlobalSection +EndGlobal diff --git a/LottoLista/LottoLista/LottoLista.csproj b/LottoLista/LottoLista/LottoLista.csproj new file mode 100644 index 0000000..2150e37 --- /dev/null +++ b/LottoLista/LottoLista/LottoLista.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/LottoLista/LottoLista/Program.cs b/LottoLista/LottoLista/Program.cs new file mode 100644 index 0000000..dfc41a2 --- /dev/null +++ b/LottoLista/LottoLista/Program.cs @@ -0,0 +1,98 @@ +using System.Security.Cryptography; + +namespace LottoLista +{ + internal class Program + { + static void Main(string[] args) + { + Console.Write("Hány számot sorsolunk?:"); + int hanySzam = Convert.ToInt32(Console.ReadLine()); + + Console.Write("Hány számból húzunk?:"); + int osszSzam = Convert.ToInt32(Console.ReadLine()); + + List tippek = new List(); + List nyeroSzamok = new List(); + List sorsoloGomb = new List(); + Random rand = new Random(); + int talalat = 0; + + + //"Sorsoló gömb" feltöltése + GombInit(osszSzam, sorsoloGomb); + + //Tippelés + Tippeles(osszSzam, hanySzam, tippek); + + Listazas(tippek); + + //Sorsolás + Sorsolas(hanySzam, nyeroSzamok, sorsoloGomb, rand); + + Listazas(nyeroSzamok); + + //Találatok meghatározása + talalat = Talalat(hanySzam, tippek, nyeroSzamok, talalat); + Console.WriteLine($"Találat:{talalat}"); + + + + } + + private static int Talalat(int hanySzam, List tippek, List nyeroSzamok, int talalat) + { + for (int i = 0; i < hanySzam; i++) + { + if (nyeroSzamok.Contains(tippek[i])) + { + talalat++; + } + } + + return talalat; + } + + private static void Sorsolas(int hanySzam, List nyeroSzamok, List sorsoloGomb, Random rand) + { + for (int i = 0; i < hanySzam; i++) + { + int kivalasztott = rand.Next(0, sorsoloGomb.Count); + nyeroSzamok.Add(sorsoloGomb[kivalasztott]); + sorsoloGomb.RemoveAt(kivalasztott); + } + } + + private static void Listazas(List lista) + { + foreach (int i in lista) + { + Console.Write(i + " "); + } + Console.WriteLine(); + } + + private static void Tippeles(int osszSzam,int hanySzam, List tippek) + { + for (int i = 0; i < hanySzam; i++) + { + Console.Write($"{i + 1}.tipp:"); + int temp = Convert.ToInt32(Console.ReadLine()); + while (temp < 1 || temp > osszSzam || tippek.Contains(temp)) + { + Console.Write($"Hiba!, Újra!{i + 1}.tipp:"); + temp = Convert.ToInt32(Console.ReadLine()); + } + tippek.Add(temp); + } + } + + private static void GombInit(int osszSzam, List sorsoloGomb) + { + for (int i = 0; i < osszSzam; i++) + { + sorsoloGomb.Add(i + 1); + } + } + } +}