Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void Shell(object sender, RoutedEventArgs e) // Сортировка Шелла
- {
- int[] localList = (int[])unsorted.Clone();
- DateTime t0 = DateTime.Now;
- int d = localList.Length / 2;
- while (d > 0)
- {
- for (int i = 0; i < localList.Length - d; i++)
- {
- if (localList[i] > localList[i + d])
- {
- int temp = localList[i];
- localList[i] = localList[i+d];
- localList[i+d] = temp;
- }
- }
- d /= 2;
- }
- for (int i = 0; i < localList.Length - 1; i++)
- {
- for (int j = i; j < localList.Length; j++)
- {
- if (localList[i] > localList[j])
- {
- int temp = localList[i];
- localList[i] = localList[j];
- localList[j] = temp;
- }
- }
- }
- DateTime t1 = DateTime.Now;
- Console.WriteLine("Время сортировки составило: " + CalculateTime(t0, t1) + " мс");
- string msg = "";
- foreach (int elem in localList)
- {
- msg += elem + ", ";
- }
- MessageBox.Show(msg);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement