用C#编写的冒泡排序小程序
来源:互联网 发布:javlibrary永久域名 编辑:程序博客网 时间:2024/06/10 10:19
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace order
{
public partial class FormOrder : Form
{
public FormOrder()
{
InitializeComponent();
}
private void buttonOrder_Click(object sender, EventArgs e)
{
int[] myArray = new int[] { 10, 8, -3, 5, 6, 7, 4, 4, 9 };
String temp = "";
for(int i=0; i<myArray.Length ; i++)
{
temp = temp +" "+ myArray[i].ToString();
}
textBoxAssay.Text = temp;
for (int i = 1; i < myArray.Length - 1; i++)
{
for (int j = 0; j < myArray.Length - i; j++)
{
if (myArray[j] > myArray[j + 1])
{
int temp2 = myArray[j];
myArray[j] = myArray[j + 1];
myArray[j + 1] = temp2;
}
}
}
String temp1 = "";
for (int i = 0; i < myArray.Length; i++)
{
temp1 = temp1 + " " + myArray[i].ToString();
}
textBoxShow.Text = temp1;
}
private void buttonSort_Click(object sender, EventArgs e)
{
String words = textBoxInput.Text;
char[] wordsTemp = words.ToCharArray();
int num = 0;
int[] myArray = new int[8];
String temp = "";
char c;
for (int i = 0; i < wordsTemp.Length; i++)
{
c = wordsTemp[i];
temp = temp + wordsTemp[i].ToString();
if (c == ' ')
{
myArray[num++] = Int32.Parse(temp);
temp = "";
}
}
for (int i = 1; i < myArray.Length - 1; i++)
{
for (int j = 0; j < myArray.Length - i; j++)
{
if (myArray[j] > myArray[j + 1])
{
int temp2 = myArray[j];
myArray[j] = myArray[j + 1];
myArray[j + 1] = temp2;
}
}
}
String temp1 = "";
for (int i = 0; i < myArray.Length; i++)
{
temp1 = temp1 + " " + myArray[i].ToString();
}
textBoxOutput.Text = temp1;
}
private void textBoxInput_TextChanged(object sender, EventArgs e)
{
}
}
}
- 用C#编写的冒泡排序小程序
- 使用java编写的冒泡排序小程序
- 用C#编写的计算器小程序
- 冒泡排序小程序
- 用Python编写数据结构的冒泡排序
- c#的冒泡排序
- C#的冒泡排序
- C#的冒泡排序
- 关于C语言冒泡排序的一段小程序。
- 汇编编写的 冒泡排序
- 用模板编写冒泡排序
- Java小程序之冒泡排序
- 冒泡排序的小插曲
- 一个简单的C#编写的小机器人对话程序
- 编写程序对N个元素数组,用冒泡排序法进行排序
- C# 可怜的冒泡排序!!!
- C#冒泡排序的实现
- C# 小程序 快速排序
- SQL Server + VS2005 + 3层结构 + EXT2.0 + ajax 的 增删改 的例子
- ASP.NET 2.0 制作彩色验证码
- ExtraFax---新一代的企业级传真服务解决方案
- rails技巧之把数据导入excel
- 显示图片 tif文件显示
- 用C#编写的冒泡排序小程序
- SecurTrac是基于Domino的安全监控软件
- 项目管理的疑惑
- UDP编程起步
- [转]ibatis +spring ,hibernate 批量操作心得
- JSON傳送與接收
- 建一个XMLHttpRequest对象池
- Yahoo UI 之AutoComplete控件
- Web Services + JSON = Dump Your Proxy