c#多维数组排序

本文关键字:数组排序 | 更新日期: 2023-09-27 18:11:33

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

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();
    }
}

c#多维数组排序

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;
            }
之间的

, 而不是哥伦布的