zoukankan      html  css  js  c++  java
  • 随机集合

    class Program
        {
            static  Random r = new Random(0);
            static void Main(string[] args)
            {
                List<string> list = new List<string> { "0""1""2""3""4""5""6""7""8""9" };
                List<string> result;
                int count = 0;
                while (count++ < 20)
                {
                    Console.WriteLine("第{0}次轮询", count);
                    list = new List<string> { "0""1""2""3""4""5""6""7""8""9" };
                    result = RadomList(list);
                    foreach (var item in result)
                    {
                        Console.Write(item+" ");
                    }
                    Console.WriteLine();
                }
                Console.Read();
            }

            private static List<string> RadomList(List<string> list)
            {
                List<string> result = new List<string>();
             
                while (list.Count > 0)
                {
                    int data = r.Next(0, list.Count);
                    result.Add(list[data]);
                    list.RemoveAt(data);
                }
                // result.Add(list[0]);
                return result;
            }
        }
  • 相关阅读:
    二分搜素——(lower_bound and upper_bound)
    二分(搜索)查找
    算法复杂度中的O(logN)底数是多少
    hdu 1050 Moving Tables
    hdu 1010 Tempter of the Bone
    hud 3123 GCC
    “123”——> 123
    基本模运算
    101个MySQL的调节和优化的Tips
    一个最简单的图片缩略图
  • 原文地址:https://www.cnblogs.com/jeriffe/p/2277833.html
Copyright © 2011-2022 走看看