static void Main(string[] args)
        {
            int[] a=new int[101];
            Random r = new Random();
            int IntervalCount=10;             

            int count = 0;
            while(count<IntervalCount-1)
            {
                int v = r.Next(99) + 1;
                if (a[v] == 1) continue;
                else
                {
                    a[v] = 1;
                    count++;
                }
            }
            a[100] = 1;
            
            int flag = 0;
            int totalCount = 0;
            for (int i = 1; i <= 100; i++)
            {
                if (a[i] == 0) continue;
                else
                {
                    Console.WriteLine(flag.ToString()+"-"+i.ToString()+".span="+(i-flag).ToString());
                    totalCount++;

                    flag = i;
                }
            }
            Console.WriteLine("lines=>" + totalCount.ToString());
            Console.ReadKey();

            
        }

 

posted on 2015-05-08 12:26  AzzStyle  阅读(1015)  评论(2编辑  收藏  举报