洗牌算法 各种技巧
洗牌算法private void Permute<T>(List<T> array) { Random random = new Random(); for (int i = 1; i < array.Count; i++) { Swap<T>(array, i, random.Next(0, i)); } } private void Swap<T>(List<T> array, int indexA, int indexB) { T temp = array[indexA]; array[indexA] = array[indexB]; array[indexB] = temp; }
标签: 洗牌