From 74ee9eaffb5e2359061b21117ef6eb02f646a0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Rudolf?= Date: Mon, 5 Oct 2026 13:01:36 +0200 Subject: [PATCH] =?UTF-8?q?=C3=9Ajraj=C3=A1tsz=C3=A1s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lotto/Lotto/Program.cs | 84 ++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 31 deletions(-) diff --git a/Lotto/Lotto/Program.cs b/Lotto/Lotto/Program.cs index 1fadc3a..7c76d28 100644 --- a/Lotto/Lotto/Program.cs +++ b/Lotto/Lotto/Program.cs @@ -21,47 +21,69 @@ //Tippek bekérése //1 és hanySzam között kell lennie //Nem lehet a tippek között + char valasz = 'n'; - for (int i = 0; i < hanySzam; i++) - { - Console.Write($"{i + 1}.tipp:"); - int temp = Convert.ToInt32(Console.ReadLine()); - //Ellenőrzés - while (temp < 1 || temp > mennyiBol || tippek.Contains(temp)) - { - Console.Write($"Rossz tipp! Újra! {i + 1}.tipp:"); - temp = Convert.ToInt32(Console.ReadLine()); - } - tippek[i] = temp; - } - Array.Sort(tippek); - Tomblista(tippek); - //Nyerőszámok sorsolása - for (int i = 0; i < hanySzam; i++) + //ciklus kezdete + do { - int temp = random.Next(1,mennyiBol+1); - while (nyeroszamok.Contains(temp)) + talalatok = 0; + + + + for (int i = 0; i < hanySzam; i++) { - temp = random.Next(1, mennyiBol + 1); + Console.Write($"{i + 1}.tipp:"); + int temp = Convert.ToInt32(Console.ReadLine()); + //Ellenőrzés + while (temp < 1 || temp > mennyiBol || tippek.Contains(temp)) + { + Console.Write($"Rossz tipp! Újra! {i + 1}.tipp:"); + temp = Convert.ToInt32(Console.ReadLine()); + } + tippek[i] = temp; } - nyeroszamok[i] = temp; - } - Array.Sort(nyeroszamok); - Tomblista(nyeroszamok); - //Találatok meghatározása - for (int i = 0; i < tippek.Length; i++) - { - for (int j = 0; j < nyeroszamok.Length; j++) + Array.Sort(tippek); + Tomblista(tippek); + + //Nyerőszámok sorsolása + for (int i = 0; i < hanySzam; i++) { - if (tippek[i] == nyeroszamok[j]) + int temp = random.Next(1,mennyiBol+1); + while (nyeroszamok.Contains(temp)) { - talalatok++; + temp = random.Next(1, mennyiBol + 1); + } + nyeroszamok[i] = temp; + } + Array.Sort(nyeroszamok); + Tomblista(nyeroszamok); + //Találatok meghatározása + for (int i = 0; i < tippek.Length; i++) + { + for (int j = 0; j < nyeroszamok.Length; j++) + { + if (tippek[i] == nyeroszamok[j]) + { + talalatok++; + } } } - } - Console.WriteLine($"Találatok száma:{talalatok}"); + Console.WriteLine($"Találatok száma:{talalatok}"); + Console.Write("Akar újra játszani? (i/n)"); + valasz = Console.ReadKey().KeyChar; + Console.WriteLine(); + + + + + }//ciklus vége + while (Char.ToLower(valasz)!='n'); + + //Fusson a program addig, amíg a megadott tippekkel el nem érünk 4 találatot. + //Írja ki a program, hogy ez hány évbe telt. + }