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 int userinput = 0;
- static int[] userszamok = new int[5];
- static int[] sorsoltszamok = new int[5];
- static int sorsolt = 0;
- static bool egyenlo = false;
- static Random rnd = new Random();
- static void Main(string[] args)
- {
- int talalatok = 0;
- userSzamokBeker();
- Console.WriteLine("\n\nTehát a tippjeid: ");
- rendezes(userszamok);
- nyeroSzamokSorsol();
- Console.WriteLine("\n\nA nyerőszámok: ");
- rendezes(sorsoltszamok);
- 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;
- }
- }
- }
- 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();
- }
- private static void rendezes(int[] tomb)
- {
- Array.Sort(tomb);
- for (int i = 0; i < 5; i++)
- {
- Console.Write(tomb[i]+", ");
- }
- }
- private static void nyeroSzamokSorsol()
- {
- 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;
- }
- }
- }
- private static void userSzamokBeker()
- {
- Console.WriteLine("Kérem a tippeket: ");
- for (int i = 0; i < userszamok.Length; i++)
- {
- 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;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement