コード例 #1
0
ファイル: Program.cs プロジェクト: isen131/MySortsLibrary
 static void Main(string[] args)
 {
     int[] a = new int[100000000];
     Random r = new Random();
     for (int i = 0; i < a.Length; i++)
     {
         a[i] = r.Next(-10000, 10000);
     }
     Sorts b = new Sorts();
     //for (int i = 0; i < a.Length; i++)
     //{
     //    Console.Write(a[i] + " ");
     //}
     //Console.ReadKey();
     var before = DateTime.UtcNow;
     //b.bubbleSort(a);
     //b.insertionSort(a);
     //b.selectionSort(a);
     b.quickSort(a,0,a.Length-1);
     //int[] c = b.mergeSort(a);
     var potracheno = DateTime.UtcNow - before;
     Console.WriteLine("Время сортировки: " + potracheno.ToString());
     Console.WriteLine();
     /*for (int i = 0; i < c.Length; i++)
     {
         Console.Write(c[i] + " ");
     }
     Console.WriteLine();*/
     /*for (int i = 0; i < a.Length; i++)
     {
         Console.Write(a[i] + " ");
     }*/
     Console.WriteLine();
     Console.ReadKey();
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: isen131/3-Sorts-WinForms
 static void Main(string[] args)
 {
     int n = 50000;
     int[] a = new int[n];
     WritingUnsortedArrayToFile(n, -50000, 50000);
     Sorts b = new Sorts();
     StreamReader sr = new StreamReader("UnsortedArray.txt");
     ReadArrayFromFile(sr, a);
     StreamWriter Bubble = new StreamWriter("Bubble.txt");
     StreamWriter insSort = new StreamWriter("insSort.txt");
     StreamWriter selSort = new StreamWriter("selSort.txt");
     var before = DateTime.UtcNow;
     //b.bubbleSort(a);
     b.insertionSort(a);
     //b.selectionSort(a);
     //b.quickSort(a,0,a.Length-1);
     var potracheno = DateTime.UtcNow - before;
     string potracheno_string = potracheno.ToString();
     WritingSortedArrayToFile(a, insSort, potracheno_string);
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: isen131/3-Sorts-WinForms
 private void SortIt_Click(object sender, EventArgs e)
 {
     Sorts b = new Sorts();
     if (a == null)
     {
         MessageBox.Show("Массив еще не создан", "Ошибка");
         return;
     }
     var before = DateTime.UtcNow;
     if (Bubble.Checked)
     {
         StreamWriter BubbleSort = new StreamWriter("Bubble.txt");
         b.bubbleSort(a);
         WritingSortedArrayToFile(a, BubbleSort);
         Status.Text = "Готово";
     }
     if (Insertions.Checked)
     {
         StreamWriter insSort = new StreamWriter("insSort.txt");
         b.insertionSort(a);
         WritingSortedArrayToFile(a, insSort);
         Status.Text = "Готово";
     }
     if (Selection.Checked)
     {
         StreamWriter selSort = new StreamWriter("selSort.txt");
         b.selectionSort(a);
         Status.Text = "Готово";
         WritingSortedArrayToFile(a, selSort);
     }
     if ((Bubble.Checked == false)&&(Insertions.Checked == false)&&(Selection.Checked == false))
     {
         Status.Text = "Ожидание действий пользователя";
         MessageBox.Show("Вы не выбрали сортировку", "Ошибка");
         return;
     }
     var potracheno = DateTime.UtcNow - before;
     string potracheno_string = potracheno.ToString();
     TimeSpend.Text = potracheno_string;
 }