Advertisement
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;
- using System.Threading.Tasks;
- namespace lotto
- {
- class Program
- {
- static void Main(string[] args)
- {
- int userinput = 0;
- int[] userszamok = new int[5];
- int[] sorsoltszamok = new int[5];
- int sorsolt = 0;
- int talalatok = 0;
- bool egyenlo = false;
- Random rnd = new Random();
- for (int i = 0; i < userszamok.Length; i++)
- {
- Console.WriteLine("Kérem az {0}. számot", i + 1);
- userinput = int.Parse(Console.ReadLine());
- for (int j = 0; j < userszamok.Length; j++)
- {
- if (userszamok[j] == userinput)
- {
- Console.WriteLine("ez már volt");
- i--;
- break;
- }
- }
- userszamok[i] = userinput;
- }
- for (int k = 0; k < sorsoltszamok.Length; k++)
- {
- sorsolt = rnd.Next(1, 20);
- for (int l = 0; l < sorsoltszamok.Length; l++)
- {
- egyenlo = false;
- if (sorsoltszamok[l] == sorsolt)
- {
- egyenlo = true;
- k--;
- break;
- }
- }
- if (egyenlo == false)
- {
- sorsoltszamok[k] = sorsolt;
- Console.WriteLine("A(z) {0}. nyerőszám: {1}", k + 1, sorsolt);
- }
- }
- for (int m = 0; m < userszamok.Length; m++)
- {
- for (int n = 0; n < sorsoltszamok.Length; n++)
- {
- if (userszamok[m] == sorsoltszamok[n])
- {
- talalatok++;
- }
- }
- }
- Console.WriteLine("\n\nA találataid száma: "+ talalatok);
- int tmp;
- int a = sorsoltszamok.Length;
- for (int o = a-1; o > 0; o--)
- {
- for (int p = 0; p < o; p++)
- {
- if (sorsoltszamok[p] > sorsoltszamok[p+1])
- {
- tmp = sorsoltszamok[p];
- sorsoltszamok[p] = sorsoltszamok[p + 1];
- sorsoltszamok[p + 1] = tmp;
- }
- }
- }
- Console.WriteLine("\n\nA nyerőszámok növekvő sorban:");
- for (int q = 0; q < sorsoltszamok.Length; q++)
- {
- Console.Write(sorsoltszamok[q] + "; ");
- }
- switch (talalatok)
- {
- case 1:
- Console.WriteLine("\n\nA nyerőszámok 20%-át találtad el.");
- break;
- case 2:
- Console.WriteLine("\n\nA nyerőszámok 40%-át találtad el.");
- break;
- case 3:
- Console.WriteLine("\n\nA nyerőszámok 60%-át találtad el.");
- break;
- case 4:
- Console.WriteLine("\n\nA nyerőszámok 80%-át találtad el.");
- break;
- case 5:
- Console.WriteLine("\n\nA nyerőszámok 100%-át találtad el.");
- break;
- default: Console.WriteLine("\n\nA nyerőszámok 0%-át találtad el.");
- break;
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement