您的位置:首页 > 编程语言 > C#

C#使用sort方法对数组进行快速排序

2015-07-29 18:36 531 查看
效果图:



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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: