Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace teszt
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string[] honapok = new string[12] { "január", "február", "március", "április", "május", "június", "július", "augusztus", "szeptember", "október", "november", "december" };
  14.             byte[] napok = new byte[12] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
  15.             byte valasz, idx_honap;
  16.  
  17.             int hibas = 0;
  18.             int jo = 0;
  19.             for (int szamolo = 0; szamolo <= 2; szamolo++)
  20.             {
  21.                 Random rnd = new Random();
  22.  
  23.                 idx_honap = Convert.ToByte(rnd.Next(0, 11));
  24.                 Console.Write("Hány napos " + honapok[idx_honap] + " hónap :");
  25.                 valasz = Convert.ToByte(Console.ReadLine());
  26.  
  27.  
  28.                 Console.WriteLine();
  29.                 if (valasz == napok[idx_honap])
  30.                 {
  31.                     Console.WriteLine("A valasz helyes!");
  32.                     jo++;
  33.  
  34.                     Console.WriteLine("Szeretnéd folytatni? (y/n)");
  35.                     if(Console.ReadKey().Key == ConsoleKey.N)
  36.                     {
  37.                         Console.Clear();
  38.                         Console.WriteLine("Nem folytattad..");
  39.                         break;
  40.                     }
  41.  
  42.                         Console.ReadKey();
  43.                     Console.Clear();
  44.                 }
  45.                 else
  46.                 {
  47.                     Console.WriteLine("A válasz helytelen!");
  48.                     hibas++;
  49.  
  50.                     Console.WriteLine("Szeretnéd folytatni? (y/n)");
  51.                     if (Console.ReadKey().Key == ConsoleKey.N)
  52.                     {
  53.                         Console.Clear();
  54.                         Console.WriteLine("Nem folytattad..");
  55.                         break;
  56.                     }
  57.                     Console.ReadKey();
  58.                     Console.Clear();
  59.                 }
  60.             }
  61.             Console.WriteLine("Jól sikerült: "+ jo +"\nHibás: " + hibas);
  62.             Console.ReadKey();
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement