C#程序按升序对二维数组元素进行排序? [英] C# program to sort a two dimensional array elements in ascending order?
本文介绍了C#程序按升序对二维数组元素进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
示例
输入:
n = 3
2 2 1
3 53 4
32 5 3
输出:< br $>
1 2 2
3 3 54
4 32 53
_________________
使用系统;
class 计划
{
静态 void Main()
{
int [] values = { 4 , 7 , 2 , 0 };
Array.Sort(values);
foreach ( int value in values)
{
Console.Write( value );
Console.Write(' ');
}
Console.WriteLine();
}
}
此代码对一维数组进行排序,但我如何对二维数组进行排序(首先对列进行排序然后对行进行排序)
解决方案
访问这些链接,他们为您的问题提供了解决方案
在C#中对二维数组进行排序 [ ^ ]
http://stackoverflow.com/questions/232395/how-do-i-sort- a-two-dimensional-in-c [ ^ ]
http://stackoverflow.com / questions / 8866414 / how-to-sort-2d-array-in-c-sharp [ ^ ]
http://channel9.msdn.com/forums/Coffeehouse/189171-Sorting-Two-Dimensional-Arrays-in-C/ [ ^
example
input :
n=3
2 2 1
3 53 4
32 5 3
output:
1 2 2
3 3 54
4 32 53
_________________
using System;
class Program
{
static void Main()
{
int[] values = { 4, 7, 2, 0 };
Array.Sort(values);
foreach (int value in values)
{
Console.Write(value);
Console.Write(' ');
}
Console.WriteLine();
}
}
this code sorts one dimensional array, but how do i sort a two dimensional array (sorting columns first and then the rows)
解决方案
Visit these links, they have given solution for your problem
Sorting a Two-Dimensional Array in C#[^]
http://stackoverflow.com/questions/232395/how-do-i-sort-a-two-dimensional-array-in-c[^]
http://stackoverflow.com/questions/8866414/how-to-sort-2d-array-in-c-sharp[^]
http://channel9.msdn.com/forums/Coffeehouse/189171-Sorting-Two-Dimensional-Arrays-in-C/[^]
这篇关于C#程序按升序对二维数组元素进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文