C#中知道一个数组,并将里面元素随机打乱的方法

it2024-10-15  17

int[,] arr={0,2,4,5,1,3,6,8}; for (int i = 0; i < num1.Length; i++) { Random random = new Random(); int tmp = arr[i]; int r = random.Next(i, arr.Length); arr[i] = arr[r]; arr[r] = tmp; }
最新回复(0)