首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

发个排序题,全当娱乐解决思路

2012-02-27 
发个排序题,全当娱乐闲的无聊,发个排序题,看看大家还记得算法不?问题:用 脚本 对100万个随机整数排序(生

发个排序题,全当娱乐
闲的无聊,发个排序题,看看大家还记得算法不?

问题:
用 "脚本 "对100万个随机整数排序(生成随机数的时间不计),然后写上你的排序时间。




[解决办法]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication8
{
public partial class Form1 : Form
{
protected List <int> L=new List <int> ();
public Form1()
{
InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)
{
System.DateTime T1=System.DateTime.Now;
L.Sort();
MessageBox.Show((System.DateTime.Now - T1).ToString());
}

private void Form1_Load(object sender, EventArgs e)
{

int max = int.MaxValue;
System.Random rnd = new Random();
for (int i = 0; i < 1000 * 1000; i++)
{
L.Add(rnd.Next(max));
}
}
}
}

---------------------------

---------------------------
00:00:00.2343735
---------------------------
OK
---------------------------

热点排行
Bad Request.