-1

Hi,

Can anyone tell me what type of sorts is my code?

static void Main(string[] args)
        {
            int[] array = { 108, 112, 87, 71, 49, 105, 49, 78, 63, 42 };
            int length = array.Length;

            int a, b, t;

            Console.Write("Original array:");
            for (int i = 0; i < length; i++)
                Console.Write(" " + array[i]);
            Console.WriteLine();

            for(a = 1; a < length; a++)
                for (b = length - 1; b >= a; b--)
                {
                    if (array[b - 1] < array[b])
                    {
                        t = array[b - 1];
                        array[b - 1] = array[b];
                        array[b] = t;
                    }
                }
            Console.Write("Sorted array: ");
            for (int i = 0; i < length; i++)
                Console.Write(" " + array[i]);
            Console.WriteLine();
            Console.ReadKey();
        }

Edited by trume: /

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by ddanbe
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.