static void Main(string[] args) { //int[] input = new int[] { -2, 1, -3, 4, -1, 2, 1, -5, 4 }; //Maximum_SubArray.Find_Max_Sum(input); //Maximum_SubArrayOpti.Find_Max_Sum(input); //int[] JPinput = new int[] { 0, 3, 1, 1, 4 }; //JumpGame JG = new JumpGame(); //JG.CanJump(JPinput); //int[] nums = { 1, 2, 3, 4, 5, 6, 7 }; //int[] nums1 = { -1, -100, 3, 99 }; //int[] nums2 = { 1,2 }; ////int[] nums = { -1 }; //int k = 3; //RotateArray RA = new RotateArray(); //RA.Rotate3(nums2, 2); //int[] input = new int[] { 0, 1, 2, 3, 4, 5 }; //RA.solution("abccbd", input); int[] input = new int[] { 6, 5, 3, 1, 8, 7, 2, 4 }; //MergeSort msort = new MergeSort(); //msort.Sort(input, 0, input.Length - 1); QuickSort qsort = new QuickSort(); qsort.Sort(input, 0, input.Length - 1); BinarySearch BS = new BinarySearch(); var res = BS.BinSearch(5, input, 0, 7); //string s = "Inndia"; //SorterCharactersFrequency sF = new SorterCharactersFrequency(); //sF.FrequencySort(s); }
static void Main(string[] args) { string line = Environment.NewLine; { Console.WriteLine("Linked List"); Console.WriteLine(line); MyLinkedList <string> LList = new MyLinkedList <string>(); LList.Add("dashulya"); LList.Add("Deniska"); foreach (string s in LList) { Console.WriteLine(s); } Console.WriteLine($"Llist contains dashulya: {LList.contains("dashulya")}"); Console.WriteLine($"Llist contains Dens: {LList.contains("Dens")}"); Console.WriteLine(line); } { Console.WriteLine("Fast Pow"); Console.WriteLine(line); for (int i = 0; i < 5; i++) { Console.WriteLine($"{i} in {i * 2} ={Pow.Recursive(i, i * 2)}"); Console.WriteLine($"{i} in {i + 2} ={Pow.Iter(i, i + 2)}"); Console.WriteLine($"{i} in {15} ={Pow.Byte(i, 15)}"); } Console.WriteLine(line); } { Console.WriteLine("Levenstain distance"); Console.WriteLine(line); Console.Write("Enter First word"); var s1 = Console.ReadLine(); Console.Write("Enter Second word"); var s2 = Console.ReadLine(); Console.WriteLine($"Расстояние Левенштейна для слов {s1} и {s2} равно {Levenstain_Distance.Find(s1, s2)}"); Console.WriteLine($"Расстояние Левенштейна для слов {s1} и {s2} равно {Levenstain_Distance.Find(s1, s2, true)}"); Console.WriteLine(line); } { Console.WriteLine("Sorts"); Console.WriteLine(line); Console.WriteLine("Sorted array: {0}", string.Join(", ", RandomSort.Sort(numbersArr))); //Can`t work with big range List <ISort> Sorts = new List <ISort>() { new BubbleSort(), new CocktailSort(), new CombSort(), new CountingSort(), new GnomeSort(), new InsertionSort(), new MergeSort(), new PancakeSort(), new QuickSort(), new SelectionSort(), new ShellSort(), new StoogeSort(), new TreeSort() }; SortStarter.Start(Sorts); Console.WriteLine(line); } RandomInt32Array rnd = new RandomInt32Array(50, -10, 25); var TestArr = rnd.Array; Console.WriteLine("Search"); Console.WriteLine(line); Console.WriteLine("Maximum ind: " + TestArr.IndOfMaximum()); Console.WriteLine("Minimum ind: " + TestArr.IndOfMinimum()); Console.WriteLine("Maximum: " + TestArr.MaximumVal()); Console.WriteLine("Minimum: " + TestArr.MinimumVal()); Console.WriteLine(line); QuickSort QS = new QuickSort(); TestArr = QS.Sort(TestArr); Console.WriteLine("TestArray 5 index " + BinarySearch.BinSearch(TestArr, 5, 0, TestArr.Length - 1)); Console.WriteLine(line); Console.WriteLine("Поиск длиннейшей общей подстроки. Введите два слова ниже"); Console.WriteLine("Общая подстрока: " + LongestComonString.Search(Console.ReadLine(), Console.ReadLine()) + line); Console.WriteLine("Граф. Поиск кратчайшего пути."); var g = DikstraHelper.CreateGraph(); var D = new DiikstraAlgoritm(g); var path = D.FindShortestPath("A", "D"); Console.WriteLine(path); Console.WriteLine(line); double f(double x) => (x * 5 - 1) / 5; var simpRes = Simpson.Integral(f, 0, 10, 1000); Console.WriteLine($"Интеграл функции х^5 от 0 до 10 равен {simpRes}" + line);; Console.ReadLine(); }