namespace _21 { internal class Program { static void Main(string[] args) { //Deklaráció string[] kartya = new string[] { "VII", "VIII", "IX", "X", "Also", "Felso", "Kiraly", "Asz" }; int[] ertek = new int[] { 7, 8, 9, 10, 2, 3, 4, 11 }; int n, i, j, sum; string lap; bool jo; //Beolvasás és számolás Console.WriteLine("21-es jatek"); Console.WriteLine("lapok:"); for (i = 0; i < 8; i++) { Console.Write(kartya[i] + "\t"); } Console.WriteLine(); Console.WriteLine("értékei"); for (i = 0; i < 8; i++) { Console.Write(ertek[i] + "\t"); } Console.WriteLine(); do { //n beolvasasa ellenorzotten Console.Write("Hány lapod van?"); jo = int.TryParse(Console.ReadLine(), out n) && n > 0 && n < 33; if (!jo) Console.WriteLine("hibás adat"); } while (!jo); // lapok beolvasasa ellenorzotten sum = 0; Console.WriteLine("Kerem a lapokat "); for (i = 0; i < n; i++) { do { Console.WriteLine("{0}. lap: ", (i + 1)); lap = Console.ReadLine(); j = 0; while (j < 8 && kartya[j] != lap) j++; if (j == 8) Console.WriteLine("Hibas lap "); else Console.WriteLine("a lap értéke: " + ertek[j]); } while (j == 8); //szamolas sum = sum + ertek[j]; } //kiiras Console.WriteLine("A kartyaid osszege: " + sum); } } }