两个数组之间的冒泡排序
来源:互联网 发布:京东全球购奶粉 知乎 编辑:程序博客网 时间:2024/04/30 18:40
int[] a = { 1, 45, 69, 48 };
int[] b = { 11, 35, 99 };
ArrayList arraylist = new ArrayList();
for (int i = 0; i < a.Length; i++)
{
arraylist.Add(a[i]);
}
for (int j = 0; j < b.Length; j++)
{
arraylist.Add(b[j]);
}
int[] temp = (int[])arraylist.ToArray(typeof(int));
for (int j = 0; j < temp.Length; j++)
{
for (int n = j - 1; n >= 0; n--)
{
if (temp[n] < temp[n + 1]) // 有小到大和由大到小改变判断即可
{
int tm = temp[n];
temp[n] = temp[n + 1];
temp[n + 1] = tm;
}
}
}
---- 第二种方法
for (int j = 0; j < temp.Length; j++)
{
for (int n = temp.Length - 1; n > j; n--)
{
if (temp[n] < temp[j])
{
int tm = temp[j];
temp[j] = temp[n];
temp[n] = tm;
}
}
}
---- 第三种
for (int j = 0; j < temp.Length; j++)
{
for (int n = j+1; n < temp.Length; n++)
{
if (temp[n] > temp[j])
{
int tm = temp[j];
temp[j] = temp[n];
temp[n] = tm;
}
}
}
for (int i = 0; i < temp.Length; i++)
{
lblarray.Text += temp[i].ToString() + ","; // 输出
}
0 0
- 两个数组之间的冒泡排序
- 冒泡排序以及两个数之间的交换
- 数组的冒泡排序
- 数组的冒泡排序.
- 数组的冒泡排序
- 数组的冒泡排序
- 数组的冒泡排序
- 数组的冒泡排序
- 数组的冒泡排序
- 数组的排序:冒泡排序、选择排序
- OC数组的冒泡排序
- 二维数组的冒泡排序
- (冒泡排序)找出数组中相差最小的两个元素
- 数组的排序(选择/冒泡/插入排序)
- 数组的选择排序和冒泡排序
- 冒泡排序实现整数数组的排序
- 用冒泡和选择法对两个数组排序
- 数组排序-冒泡排序
- Linq to DataTable 操作
- 锁存器不爱触发器
- php返回json数据
- ASP.NET中使用System.Net.Mail发邮件
- android仿ios开关按钮
- 两个数组之间的冒泡排序
- ----- asp.net传递汉字处理
- easyui datagrid删除指定行checkbox 和禁用
- 第三周项目1 顺序表的基本运算(3)
- C# 遍历循环多维数组
- Lucene.net 搜索引擎技术 及分页
- 2016年 书单
- 多道编程与多用户环境
- asp.net 解决用户重复刷新按钮问题