c# 合并数组后排序输出
来源:互联网 发布:oracle清空表空间数据 编辑:程序博客网 时间:2024/05/16 05:48
protected void Page_Load(object sender, EventArgs e)
{
int[] a ={ 4, 3 };
int[] b ={ 1, 2 };
int[] arr1 = { 1, 2, 3, 4 };
int[] arr2 = { 2, 3, 45, 6, 7 };
int[] arr3 = { 4, 5, 6, 7, 8 };
int[] result = CompoundArray(arr1, arr2, arr3);
foreach (int i in result)
Response.Write(i);
getArray2(a, b);
getHeBingArray();
}
1:
public int[] Maopao(int[] items)
{
for(int i=0;i<items.Length;i++)
{
for(int j=0;j<items.Length-1-i;j++)
{
if(items[j]>items[j+1])
{
int temp=items[j];
items[j] = items[j + 1];
items[j + 1] = temp;
}
}
}
return items;
}
private void getArray2(int[] left, int[] right)
{
if (left == null || right == null)
{
throw new ArgumentException("not");
}
int[] result = new int[left.Length + right.Length];
int mIdex = 0;
for (int i = 0; i < result.Length; i++)
{
if (i < left.Length)
{
result[i] = left[mIdex++];
}
else
{
result[i] = right[i - left.Length];
}
}
result=Maopao(result);
foreach (int aa in result)
{
Response.Write(aa + "<br>");
}
}
转:
2:
public static int[] CompoundArray(params int[][] arrays)
{
List<int> list = new List<int>();
foreach (int[] arr in arrays)
list.AddRange(arr);
return list.ToArray();
}
3:
public void getHeBingArray()
{
int[] a = new int[12] { 1, 3, 5, 7, 9, 12,0,0,0,0,0,0};
int[] b = new int[5] { 10, 8, 6, 4, 2 };
b.CopyTo(a, 5);
Array.Sort(a);
foreach (int var in a)
{
Response.Write(var + "<br>");
}
}
- c# 合并数组后排序输出
- C# 合并两个int数组 合并后根据大小排序 并输出
- 【Java实现】给出两个整型数组,将他们合并后从小到大排序并输出
- 将两个整形数组排序后合并成一个数组
- 利用可变数组将用户输入数字排序后输出
- 合并两个排序数组
- [排序数组合并]
- 合并两个排序数组
- 合并已排序数组
- 合并排序数组 II
- 题目:合并排序数组
- LintCode 合并排序数组
- 合并排序数组
- LintCode: 合并排序数组
- lintcode ----合并排序数组
- 排序数组合并
- LintCode:合并排序数组
- 合并排序数组 II
- String和StringBuffer——字符串性能优化总结
- Remoting实验,基础部分和接口事件
- 《Java程序员职场全功略:从小工到专家》连载四:IT人不容易
- 怎样做sns网站?哪里可下载这类程序?
- Java学习方法
- c# 合并数组后排序输出
- Ubuntu 下安装GTK+
- 2010-3-10
- [架构] 大型网站架构系列之三 ---------------- 多对多关系的优化设计
- creative companies
- Windows2003之IIS6.0的配置
- GlobalAlloc and VirtualAlloc
- SEO必备技巧55条
- JDK1.6下载安装和环境配置