任务只是通过我(我们)学到的这些东西来解决问题。我的程序正在运行,除了我得到重复的随机数。请帮忙怎么做,我尝试了半天:(
int[] lotto = new int[6];
Random rnd = new Random();
int i;
int max, min;
for (i = 0; i < 6; i++)
{
lotto[i] = rnd.Next(1, 46);
Console.Write("{0} ", lotto[i]);
}
max = lotto[0];
min = lotto[0];
for (i = 0; i < 6; i++)
{
if (lotto[i] > max) max = lotto[i];
if (lotto[i] < min) min = lotto[i];
}
Console.WriteLine("\nthe smallest num: {0} the biggest num: {1}", min, max);
Console.ReadKey();