c#多维数组排序



我一直在尝试排序多维数组,但不幸的是我无法做到这一点。它是一个整数数组,用户可以把它的维度,它的元素,并得到结果降序。这是我所做的。由于

class Program
{
    static void Main(string[] args)
    {
        int rows;
        int columbs;
        Console.WriteLine("Enter the number of rows");
        rows = int.Parse(Console.ReadLine());
        Console.WriteLine("Enter the number of columbs");
        columbs = int.Parse(Console.ReadLine());
        int[,] number = new int[rows, columbs];
        Console.WriteLine("Enter the elements of the array");
        for (int i = 0; i < rows; i++)
        {
            for (int y = 0; y < columbs; y++)
            {
                number[i, y] = int.Parse(Console.ReadLine());
            }
        }
        int a;
        int z;
        int w;
        for (w = 0; w < rows; w++)
        {
            for (z = 0; z < columbs; z++)
                if (number[w, z] < number[w, z++])
                {
                    a = number[w, z++];
                    number[w, z++] = number[w, z];
                    number[w, z] = a;
                }
        }
        Console.WriteLine();
        foreach (int k in number)
        {
            Console.WriteLine(k);
        }
        Console.ReadKey();
    }
}
if (z+1 < columbs && number[w, z] < number[w, z+1])
            {
                a = number[w, z+1];
                number[w, z+1] = number[w, z];
                number[w, z] = a;
            }
之间的

, 而不是哥伦布的

相关内容

  • 没有找到相关文章

最新更新