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); } }
本文来自博客园,作者:阿霖找BUG,转载请注明原文链接:https://www.cnblogs.com/lin-07/p/17551759.html