From 47eae1a89e869ff5ae62a86495361dbffa52eab8 Mon Sep 17 00:00:00 2001 From: nagynandorrobert Date: Thu, 21 Sep 2023 10:16:14 +0200 Subject: [PATCH] =?UTF-8?q?k=C3=A9sz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kosar2004/Program.cs | 49 ++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/kosar2004/Program.cs b/kosar2004/Program.cs index e513900..5ff8485 100644 --- a/kosar2004/Program.cs +++ b/kosar2004/Program.cs @@ -21,6 +21,32 @@ namespace Balkezesek progi.Feladat7(); } + + public void Feladat7() + { + Dictionary stadionok = new Dictionary(); + + foreach (var item in kosar) + { + if (stadionok.ContainsKey(item.helyszin)) + { + stadionok[item.helyszin]++; + } + else + { + stadionok.Add(item.helyszin, 1); + } + } + + foreach (KeyValuePair st in stadionok) + { + if (st.Value > 20) + { + Console.WriteLine($"{st.Key}: {st.Value}"); + } + } + } + public void Beolvasas(string fajlnev) { StreamReader sr = new StreamReader(fajlnev, Encoding.UTF8); @@ -87,28 +113,7 @@ namespace Balkezesek } } - /* - public void Feladat7() - { - int alkalom = 0; - - foreach (var item in kosar) - { - for (int i = 0; i < kosar.Count; i++) - { - if (item.helyszin[i] == item.helyszin[i-1]) - { - alkalom++; - if (alkalom > 20) - { - Console.WriteLine(item.helyszin+": "+ alkalom); - } - } - } - - } - } - */ + } }