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)
{
char k = 'l';
while (!(k == 'k'))
{
Random rnd = new Random();
int[] tablica = new int[6];
for (int i = 0; i < 6; i++)
{
tablica[i] = 0;
}
for (int i = 0, z; i < 6; i++)
{
{
z = rnd.Next(1, 49);
while (tablica.Contains(z))
{
z = rnd.Next(1, 49);
}
tablica[i] = z;
}
}
Array.Sort(tablica);
foreach (int q in tablica)
{
Console.Write(q);
Console.Write(", ");
}
k = Convert.ToChar(Console.Read()) ;
Console.WriteLine("\n\n\n");
}
}
}
}
It works alright. When I use the step by step clickage (F10 in visual studio), it runs fine. But when I run it normally, then after the
k=Convert.ToChar(Console.Read());
when I supply 'k', the program stops, as intended. when I supply nothing, it does the
foreach (int q in tablica)
{
Console.Write(q);
Console.Write(", ");
}
k = Convert.ToChar(Console.Read()) ;
Console.WriteLine("\n\n\n");
two times, and when I supply anything other than 'k' it does it three times. What.The.Hell.