示例#1
0
        public void DisplayArrayAndString()
        {
            Console.WriteLine("Select Question[1-10]");
            int choice = int.Parse(Console.ReadLine());

            switch (choice)
            {
                #region Max Sub Array Sum Using Kadens Algo
            case 1:
                Console.WriteLine("--------" + choice + ".Max Sub Array Sum Using Kadens Algo--------");
                FindMaxSubArraySumUsingKadensAlgo o1 = new FindMaxSubArraySumUsingKadensAlgo();
                int[] arr1 = { 2, -1, -3, 4, -1, 7, -2 };
                Console.WriteLine(o1.MaxSub(arr1));
                break;
                #endregion

                #region Binary Search
            case 2:
                Console.WriteLine("--------" + choice + ".Binary Search--------");
                BinarySearch o2   = new BinarySearch();
                int[]        arr2 = { 5, 10, 20, 30, 40 };
                Console.WriteLine(o2.BSEarch(arr2, 0, arr2.Length - 1, 40));
                break;
                #endregion

                #region Check Palindrome
            case 3:
                Console.WriteLine("--------" + choice + ".Check Palindrome--------");
                StringPalindrome o3 = new StringPalindrome();
                Console.WriteLine("Enter a String to check Palindrome or not");
                string str3 = Console.ReadLine();
                Console.WriteLine($"{str3} is palindrome {o3.CheckPalindrome(str3)}");
                break;
                #endregion

                #region Bubble Sort
            case 4:
                Console.WriteLine("--------" + choice + ".Bubble Sort--------");
                int[]      arr = { 1, 2, 3, 4 };
                BubbleSort o4  = new BubbleSort(arr, arr.Length);
                break;
                #endregion

                #region Insertion Sort
            case 5:
                Console.WriteLine("--------" + choice + ".Insertion Sort--------");
                var o5 = new InsertionSort(new int[] { 8, 4, 1, 5 });
                break;
                #endregion

                #region Selection sort
            case 6:
                Console.WriteLine("--------" + choice + ".Selection Sort--------");
                var o6 = new SelectionSort(new int[] { 4, 6, 9, 2, 3, 1 });
                break;
                #endregion

                #region Quick Sort
            case 7:
                Console.WriteLine("--------" + choice + ".Quick Sort--------");
                var o7 = new SelectionSort(new int[] { 4, 6, 9, 2, 3, 1 });
                break;
                #endregion

                #region Merge Sort
            case 8:
                Console.WriteLine("--------" + choice + ".Merge Sort--------");
                var o8 = new MergeSort(new int[] { 4, 6, 9, 2, 3, 1 });
                break;
                #endregion

                #region
            case 9:
                Console.WriteLine("--------" + choice + ".String Reverse--------");
                Console.WriteLine($"Test the String Reverse! : { ReverseString.Reverse("Test the String Reverse!")}");
                break;
                #endregion

                #region
            case 10:
                Console.WriteLine("--------" + choice + ".--------");

                break;
                #endregion

            default:
                Console.WriteLine("Oops! Inavalid Choice.");
                break;
            }
        }