Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static int[] randomszamok = new int[5];
- static int[] tipp = new int[5];
- static int tipp1;
- static int tipp2;
- static int tipp3;
- static int tipp4;
- static int tipp5;
- static int talalat = 0;
- static void Main(string[] args)
- {
- {
- Random rnd = new Random();
- for (int i = 0; i < 5; i++)
- {
- randomszamok[i] = rnd.Next(1, 38);
- }
- tippbekeres();
- }
- }
- static void tippbekeres()
- {
- bool done = false;
- do
- {
- try
- {
- int c = 1;
- for (int i = 0; i < 5; i++ )
- {
- Console.WriteLine("Add meg a(z)" + c++ + "-edik tipped!(1-től 38-ig) ");
- tipp[i] = Convert.ToInt16(Console.ReadLine());
- if (tipp[i] > 38 || tipp[i]<0)
- {
- Console.WriteLine("A tippnek 0 és 38 között kell lennie!");
- Console.ReadLine();
- }
- }
- talalatok();
- }
- catch (FormatException)
- {
- Console.WriteLine("Csak számot adhatsz meg!");
- continue;
- }
- tipp1 = tipp[0];
- tipp2 = tipp[1];
- tipp3 = tipp[2];
- tipp4 = tipp[3];
- tipp5 = tipp[4];
- } while (!done);
- }
- static void talalatok()
- {
- for (int i = 0; i < 5; i++)
- {
- if (tipp[0] == randomszamok[i] || tipp[1] == randomszamok[i] || tipp[2] == randomszamok[i] || tipp[3] == randomszamok[i] || tipp[4] == randomszamok[i])
- {
- talalat++;
- }
- }
- Console.WriteLine("Ennyi találatod lett:" + talalat);
- Console.WriteLine("A kitalált számok:");
- Console.WriteLine(randomszamok[0]);
- Console.WriteLine(randomszamok[1]);
- Console.WriteLine(randomszamok[2]);
- Console.WriteLine(randomszamok[3]);
- Console.WriteLine(randomszamok[4]);
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment