資源簡介
好東西,絕對好東西.看了就明白
C# 冒泡排序 .net 排序算法 動態演示程序
C# 冒泡排序 .net 排序算法 動態演示程序
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?System.Threading;
using?System.Diagnostics;
namespace?Sort
{
????public?partial?class?Form2?:?Form
????{
????????int?step?=?0start=0state=0;
????????int?amend?=?0;
????????public?int[]?randNums;
????????Form?demo;
????????Label[]?labels;
????????Label?signexplain;
????????Button?startButton?stepButton;
????????int?srcX?srcY?targetX?targetYindexIindexJ;
????????int?i?=?0i1=0m;
????????bool?flag?=?true;
????????public?Form2()
????????{
????????????InitializeComponent();
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????ShowRandom(10);
????????}
????????public?void?ShowRandom(int?num)
????????{
????????????if?(label1.Text?!=?““)?label1.Text?=?““;
????????????randNums=new?int[num];
????????????Random?rand?=?new?Random();
????????????for?(int?i?=?0;?i?????????????{
????????????????randNums[i]?=?rand.Next(10);
????????????????label1.Text?+=?randNums[i]?+?“??“;
????????????}
????????}
????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????amend?=?0;
????????????if?(randNums?==?null)
????????????{
????????????????MessageBox.Show(“請先生成隨機數“);
????????????????return;
????????????}
????????????demo?=?new?Form();
????????????demo.StartPosition?=?System.Windows.Forms.FormStartPosition.CenterScreen;
????????????demo.Size?=?new?System.Drawing.Size(Screen.GetWorkingArea(this).Width?Screen.GetWorkingArea(this).Height);
????????????demo.Text?=?“通用冒泡過程觀看“;
????????????stepButton?=?new?Button();
????????????stepButton.Location?=?new?System.Drawing.Point(850?100);
????????????stepButton.Size?=?new?System.Drawing.Size(90?25);
????????????stepButton.Text?=?“單步觀看“;
????????????stepButton.Click?+=?new?System.EventHandler(this.stepButton_Click);
????????????demo.Controls.Add(stepButton);
????????????startButton?=?new?Button();
????????????startButton.Location?=?new?System.Drawing.Point(850?150);
????????????startButton.Size?=?new?System.Drawing.Size(90?25);
????????????startButton.Text?=?“連續觀看“;
????????????startButton.Click?+=?new?System.EventHandler(this.startButton_Click);
????????????demo.Controls.Add(startButton);
????????????explain?=?new?Label();
????????????explain.AutoSize?=?true;
????????????explain.ForeColor?=?Color.Red;
????????????explain.Location?=?new?System.Drawing.Point(1802);
????????????explain.Font?=?new?Font(Font.SystemFontName?13);
????????????demo.Controls.Add(explain);
????????????Label?title?=?new?Label();
????????????title.SetBounds(800?200200450);
????????????title.Text?=?“冒泡排序(Bubble?sort)是基于交換排序的一種算法。它是依次兩兩比較待排序元素;若為逆序(遞增或遞減)則進行交換,將待排序元素從左至右比較一遍稱為一趟“冒泡”。?每趟冒泡都將待排序列中的最大關鍵字交換到最后(或最前)位置。直到全部元素有序為止。“;
????????????title.Font?=?new?Font(Font.SystemFontName?9);
????????????demo.Controls.Add(title)
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????28672??2008-05-15?10:41??Sort\Sort\bin\Debug\Sort.exe
?????文件??????36352??2008-05-15?10:41??Sort\Sort\bin\Debug\Sort.pdb
?????文件???????5632??2005-12-08?06:51??Sort\Sort\bin\Debug\Sort.vshost.exe
?????文件??????????2??2008-05-04?02:44??Sort\Sort\ClassDiagram1.cd
?????文件??????14738??2008-05-15?10:09??Sort\Sort\Form2.cs
?????文件???????6001??2008-05-04?01:35??Sort\Sort\Form2.Designer.cs
?????文件???????6401??2008-05-04?01:35??Sort\Sort\Form2.resx
?????文件????????777??2008-05-15?10:37??Sort\Sort\input.cs
?????文件???????3153??2008-05-03?09:54??Sort\Sort\input.Designer.cs
?????文件???????5814??2008-05-03?09:54??Sort\Sort\input.resx
?????文件????????958??2008-05-15?10:08??Sort\Sort\obj\Debug\Sort.csproj.GenerateResource.Cache
?????文件??????28672??2008-05-15?10:41??Sort\Sort\obj\Debug\Sort.exe
?????文件????????181??2008-05-04?01:44??Sort\Sort\obj\Debug\Sort.Form2.resources
?????文件????????181??2008-05-03?10:03??Sort\Sort\obj\Debug\Sort.Input.resources
?????文件??????36352??2008-05-15?10:41??Sort\Sort\obj\Debug\Sort.pdb
?????文件????????181??2008-05-02?12:25??Sort\Sort\obj\Debug\Sort.Properties.Resources.resources
?????文件????????279??2008-05-15?10:47??Sort\Sort\obj\Sort.csproj.FileList.txt
?????文件????????464??2008-05-15?10:36??Sort\Sort\Program.cs
?????文件???????1164??2008-05-02?12:17??Sort\Sort\Properties\AssemblyInfo.cs
?????文件???????2863??2008-05-02?12:17??Sort\Sort\Properties\Resources.Designer.cs
?????文件???????5612??2008-05-02?12:17??Sort\Sort\Properties\Resources.resx
?????文件???????1088??2008-05-02?12:17??Sort\Sort\Properties\Settings.Designer.cs
?????文件????????250??2008-05-02?12:17??Sort\Sort\Properties\Settings.settings
?????文件???????3595??2008-05-04?02:44??Sort\Sort\Sort.csproj
?????文件????????596??2008-05-04?04:50??Sort\Sort\Sort.csproj.user
?????文件????????901??2008-05-15?10:38??Sort\Sort.sln
????..A..H.?????20480??2008-05-15?10:38??Sort\Sort.suo
?????目錄??????????0??2008-05-15?10:08??Sort\Sort\obj\Debug\TempPE
?????目錄??????????0??2008-05-06?12:59??Sort\Sort\bin\Debug
?????目錄??????????0??2008-05-15?10:41??Sort\Sort\obj\Debug
............此處省略8個文件信息
- 上一篇:遠程監控(C#源代碼)
- 下一篇:C#處理png圖片位深度和交錯屬性
評論
共有 條評論