static void Main(string[] args) { Console.WriteLine("输入数字"); string numbers = Console.ReadLine(); string[] number = numbers.Trim().Split(' '); int[] data = new int[number.Length]; for (int i = 0; i < number.Length; i++) { data[i] = Convert.ToInt32(number[i]); } Console.WriteLine("选择排序法:"); int[] selectsort = SelectSort.Select(data); Write(selectsort); Console.WriteLine("插入排序法:"); int[] isnertsort = InsertSort.Insert(data); Write(isnertsort); Console.WriteLine("冒泡排序法:"); int[] bubblesort = BubbleSort.Bubble(data); Write(bubblesort); Console.WriteLine("希尔排序法:"); int[] shellsort = ShellSort.Shell(data); Write(shellsort); Console.WriteLine("堆排序法:"); int[] halfsort = HeapSort.Heap(data); Write(halfsort); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); int[] arr = { 55, 25, 89, 34, 12, 19, 78, 95, 1, 100 }; HeapSort.heapSort(arr, arr.Length); }
static void Main(string[] args) { HeapSort heapSort = new HeapSort(); heapSort.ConstructHeap(); #region QuickSort //QuickSortAlgorithm obj = new QuickSortAlgorithm(); // obj.Sort(); #endregion Console.Read(); }
private static void Main() { ISortableCollection<Item> sortableCollection = new SortableCollection<Item>(); //new[] //{ // new Item(12), // new Item(34), // new Item(12), // new Item(3.5), // new Item(4.7), // new Item(0.67) //}); //sortableCollection.AddRange(new[] //{ // new Item(45), // new Item(5.6), // new Item(12.5), // new Item(1.2), // new Item(340), // new Item(155), // new Item(30.5), // new Item(4.76), // new Item(0.174) //}); Random random = new Random(); Enumerable.Range(0, 1000).ToList().ForEach(e => sortableCollection.Add(new Item(random.Next(e) * random.NextDouble()))); ISortableCollection<Item> collection1 = sortableCollection.Clone(); ISortableCollection<Item> collection2 = sortableCollection.Clone(); ISortableCollection<Item> collection3 = sortableCollection.Clone(); collection1.Remove(collection1[0]); collection2.RemoveAt(collection2.Count - 1); SortAlgorithm<Item> selectionSort = new SelectionSort<Item>(); SortAlgorithm<Item> shakeSort = new ShakeSort<Item>(); SortAlgorithm<Item> heapSort = new HeapSort<Item>(); selectionSort.Sort(collection1); shakeSort.Sort(collection2); heapSort.Sort(collection3); Console.WriteLine(selectionSort); Console.WriteLine(shakeSort); Console.WriteLine(heapSort); Console.ReadKey(); }
static void Main(string[] args) { HeapSort s = new HeapSort(); int[] v = { 0, 8, 56, 2, 67, 98, 100 }; s.heapSort(v); for (int i = 1; i < v.Length; i++) { Console.Write(v[i] + " "); } Console.WriteLine(); GenericHS <Double> h1 = new GenericHS <Double>(); double[] v2 = { 0, 8.3, 56.9, 56.11, 67.3, 98.9, 100 }; h1.heapSort(v2); for (int i = 1; i < v2.Length; i++) { Console.Write(v2[i] + " "); } Console.WriteLine(); }
static void Main(string[] args) { HeapSort heapSort = new HeapSort(); heapSort.ConstructHeap(); }
static void Main(string[] args) { //Оратівський Сергій. ПЗС-2044. 2020р. Console.WriteLine("Оратiвський Сергiй. ПЗС-2044"); int[] masBubble = new int[5] { 5, 1, 6, 12, 4 }; SortedBubble sortB = new SortedBubble(); sortB.SortedBuble(masBubble); Console.WriteLine("Сортировка пузырьком"); for (int i = 0; i < 5; i++) { Console.Write(masBubble[i] + " "); } Console.WriteLine(" "); int[] masInsert = new int[5] { 653, 27, 323, 12, 534 }; SortedInser sortI = new SortedInser(); sortI.SortedInsert(masInsert); Console.WriteLine("Сортировка вставками"); for (int i = 0; i < 5; i++) { Console.Write(masInsert[i] + " "); } Console.WriteLine(" "); int[] masVibor = new int[5] { 34, 1, 8543, 23, 5 }; SortedSelect sort1 = new SortedSelect(); sort1.SortedSelection(masVibor); Console.WriteLine("Сортировка выбором"); for (int i = 0; i < 5; i++) { Console.Write(masVibor[i] + " "); } Console.WriteLine(" "); int[] arr = { 845, 235, 6452, 534, 534 }; int n = arr.Length; HeapSort piramid = new HeapSort(); piramid.sort(arr); Console.WriteLine("Пирамидальная сортировка:"); for (int i = 0; i < n; i++) { Console.Write(arr[i] + " "); } Console.WriteLine(" "); int[] masSortedTest = { 4457, 4523, 732, 734, 664 }; SortedTest sortTest1 = new SortedTest(); sortTest1.SortedTest1(masSortedTest); Console.WriteLine("Сортировка ..."); for (int i = 0; i < n; i++) { Console.Write(masSortedTest[i] + " "); } Console.WriteLine(" "); }