这几天无聊,就去研究排序算法,话不多说,用事实说话。
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Diagnostics;
namespace 排序算法大PK
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("规则:取20000随机数,比较各自耗时");
for (int i = 0; i < 5; i++)
{
List<int> list = new List<int>();
//取20000个随机数到集合中
for (int j = 0; j < 20000; j++)
{
Thread.Sleep(1);
list.Add(new Random((int)DateTime.Now.Ticks).Next(0, 1000000));
}
Console.WriteLine("\n第" + i + "轮PK:");
Stopwatch wa