예제 #1
0
        /// <summary>
        /// Starts input.
        /// </summary>
        /// <returns> Returns entered array. </returns>
        public static int[] StartInput()
        {
            int N, min, max;

            int[] arr = null;
            Console.WriteLine("Please enter the size of an array you want to sort");
            Console.Write("N = ");
            N = int.Parse(Console.ReadLine());
            Console.WriteLine("Enter the boundaries of array");

            //entering lower boundary of array
            Console.Write("MinValue = ");
            min = int.Parse(Console.ReadLine());

            //entering upper boundary of array
            Console.Write("MaxValue = ");
            max = int.Parse(Console.ReadLine());

            //generating an array of random ints
            arr = Utilities.RandArrGen(N, min, max);
            Console.WriteLine("This is your array consisted of random ints");

            //printing already generated array
            Utilities.PrintArray(arr);
            Console.WriteLine("Select which algorithm you want to perform");
            Console.WriteLine("1.Insertion sort.\n" +
                              "2.Bubble sort.\n" +
                              "3.Quick sort.\n" +
                              "4.Heap sort.\n" +
                              "5.Merge sort.\n" +
                              "6.All");
            return(arr);
        }
예제 #2
0
        public void Run()
        {
            int[] nums = { 0, 0, 1, 1, 1, 2, 2, 3, 3, 4 };
            nums = new int[] { 1, 1, 1, 1 };


            var length = RemoveDuplicate(nums);

            Utilities.PrintArray(nums, length);
        }
예제 #3
0
        public void Run()
        {
            int[] arr    = new[] { 1 };
            int   val    = 1;
            var   length = RemoveElement(arr, val);

            //Utilities.PrintArray(arr, length);

            length = RemoveElementSwap(arr, val);
            Utilities.PrintArray(arr, length);
        }