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;
- namespace Lottokupon
- {
- class Program
- {
- public static Random rnd = new Random();
- public static int favoritNum = 0;
- static void Main(string[] args)
- {
- Console.WriteLine("Indtast nu dit favorit tal!");
- int favoritNum = int.Parse(Console.ReadLine());
- Console.WriteLine("Hvor mange rækker ønsker du på din lotto kupon?");
- int reakker = int.Parse(Console.ReadLine());
- Console.WriteLine("Du har valgt købe {0} rækker på din lotto kupon", reakker);
- for (int i = 1; i <= reakker; i++)
- {
- Console.Write("Række {0}: ", i);
- RandomNum();
- Console.Write("\n");
- }
- Console.ReadKey();
- }
- //Her udregner vi vores random nummer, og tjekker om det er blevet udregnet 1 gang i forvejen.
- public static void RandomNum()
- {
- List<int> list = new List<int>();
- while (list.Count < 7)
- {
- int randnum = rnd.Next(1, 37);
- if (!list.Contains(favoritNum))
- {
- list.Add(favoritNum);
- }
- else if (!list.Contains(randnum))
- {
- list.Add(randnum);
- if (randnum > 9)
- {
- Console.Write(randnum + " ");
- }
- else
- {
- Console.Write("0" + randnum + " ");
- }
- }
- else
- {
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement