/// <summary>
        /// 洗牌算法
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="listtemp"></param>
        public void Reshuffle<T>(List<T> listtemp)
        {
            //随机交换
            Random ram = new Random();
            int currentIndex;
            T tempValue;
            for (int i = 0; i < listtemp.Count; i++)
            {
                currentIndex = ram.Next(0, listtemp.Count - i);
                tempValue = listtemp[currentIndex];
                listtemp[currentIndex] = listtemp[listtemp.Count - 1 - i];
                listtemp[listtemp.Count - 1 - i] = tempValue;
            }
        }

相关文章:

  • 2021-11-16
  • 2022-12-23
  • 2021-05-20
  • 2022-12-23
  • 2021-10-24
  • 2021-07-15
猜你喜欢
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2022-02-12
相关资源
相似解决方案