C#使用sort方法對陣列進行快速排序
效果圖:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 使用sort方法對陣列進行快速排序
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int[] j = new int [10];
private void button1_Click(object sender, EventArgs e)
{
Random r = new Random();
for (int i = 0; i < 10; i++)
{
int sum = r.Next(0,100);
j[i] = sum;
textBox1.Text += sum.ToString()+",";
}
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox1 != null)
{
Array.Sort(j);
foreach (int i in j)
{
textBox2.Text += i.ToString()+",";
}
}
}
}
}
資源下載地址:http://download.csdn.net/detail/qq_28597703/8944115