产生一个int数组,长度为100,并向其中随机插入1-100,并且不能重复
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 测试 { class Program { static void Main(string[] args) { List<int>arr=new List<int>(); int[]newArr=new int[100]; for (int i = 1; i <= 100; i++) { arr.Add(i); } for (int p = 0; p < 100; p++) { Random random=new Random(); int j = random.Next(0, arr.Count); newArr[p] = arr[j]; arr.RemoveAt(j); } foreach (int i in newArr) { Console.WriteLine(i); } Console.ReadKey(); } } }