public void nums() { ArrayList list = new ArrayList(); Random r = new Random(); list.Add(r.Next(20)); while (true) { if (list.Count == 20) break; int num = r.Next(1,21); if (list.Contains(num)) { continue; } else{ list.Add(num); } } foreach(int i in list) { Console.WriteLine(i); } }
标签:20,int,list,Next,Add,num,随机,集合 From: https://www.cnblogs.com/lin-07/p/17551759.html