Inserts a random number between 1 and 100 into an array
- 2020-06-23 01:51:00
- OfStack
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
List<int> list = new List<int>();
Random ran = new Random();
while(true)
{
if (list.Count >= 100)
{
break;
}
int s = ran.Next(1, 101);
if (!list.Contains(s))
{
list.Add(s);
}
}
list.Sort();
foreach (int i in list)
{
Console.Write(i + " ");
}
Console.ReadKey();
}
}
}