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 Random rnd = new Random();
- static void Main(string[] args)
- {
- // szamok[2] = 9; 2. indexű elem felülíródik 9-re
- // szamok.Instert(2,20); új elem létrejön 2. helyre a 2. és utána lévők 1-el nőnek.
- // szamok.RemoveAt(2); kitörli a 2. elemet
- int db = 5;
- int min = 1;
- int max = 90;
- int index;
- int veletlen;
- bool letezik;
- int tipp;
- List<int> lottoSzamok = new List<int>();
- List<int> tippek = new List<int>();
- List<int> talalatok = new List<int>();
- index = 0;
- while (index < db)
- {
- letezik = false;
- veletlen = rnd.Next(min, max + 1);
- for (int i = 0; i < lottoSzamok.Count; i++)
- {
- if (lottoSzamok[i] == veletlen)
- letezik = true;
- }
- if (!letezik)
- {
- lottoSzamok.Add(veletlen);
- index++;
- }
- }
- index = 0;
- while (index < db)
- {
- letezik = false;
- do
- {
- Console.Write("{0}. tipp: ", index + 1);
- } while (!int.TryParse(Console.ReadLine(), out tipp) || tipp < min || tipp > max);
- veletlen = rnd.Next(min, max + 1);
- for (int i = 0; i < tippek.Count; i++)
- {
- if (tippek[i] == tipp)
- letezik = true;
- }
- if (!letezik)
- {
- tippek.Add(tipp);
- index++;
- }
- }
- Console.Clear();
- Console.WriteLine("Az eheti lottószámok:");
- for (int i = 0; i < lottoSzamok.Count - 1; i++)
- Console.Write("{0}, ", lottoSzamok[i]);
- Console.WriteLine(lottoSzamok[lottoSzamok.Count-1]);
- Console.WriteLine("Az Ön Tippjei:");
- for (int i = 0; i < tippek.Count - 1; i++)
- Console.Write("{0}, ", tippek[i]);
- Console.WriteLine(tippek.Last());
- for (int i = 0; i < lottoSzamok.Count; i++)
- {
- for (int j = 0; j < tippek.Count; j++)
- {
- if (lottoSzamok[i] == tippek[j])
- talalatok.Add(lottoSzamok[i]);
- }
- }
- Console.WriteLine("Önnek {0} találata van: ", talalatok.Count);
- if (talalatok.Count == 0)
- Console.WriteLine("-");
- else
- {
- for (int i = 0; i < talalatok.Count - 1; i++)
- Console.Write("");
- }
- for (int i = 0; i < lottoSzamok.Count - 1; i++)
- Console.Write("{0}, ", lottoSzamok[i]);
- Console.WriteLine(lottoSzamok[lottoSzamok.Count-1]);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement