using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Sort { public partial class Form1 : Form { int[] pole_b = new int[100000]; int[] pole_q = new int[100000]; int[] pole_a = new int[100000]; int pocet; StringBuilder sb_b = new StringBuilder(); StringBuilder sb_q = new StringBuilder(); StringBuilder sb_a = new StringBuilder(); int klik_b = 0; int klik_q = 0; int klik_a = 0; char pad = ' '; public void BubbleSort(int[] pole) { int pom; int max = pocet; bool konec; do { konec = false; for (int i = 1; i < max; i++) { if (pole[i - 1] > pole[i]) { konec = true; pom = pole[i - 1]; pole[i - 1] = pole[i]; pole[i] = pom; } } max--; } while (konec); } public void QuickSort(int[] pole, int l, int r) { int zacatek; int konec; if (l < r) { int pivot = pole[(l + r) / 2]; // pivot nastaven na prostřední prvek oblasti zacatek = l; konec = r; do { while (pole[zacatek] < pivot) { zacatek++; } while (pole[konec] > pivot) { konec--; } if (zacatek <= konec) { swap(pole, zacatek, konec); zacatek++; konec--; } } while (!(zacatek > konec)); // Rozdělení je dokončeno, nové intervaly jsou a if (konec - l <= r - zacatek) //kratší úsek třídíme nejprve { QuickSort(pole, l, konec); QuickSort(pole, zacatek, r); } else { QuickSort(pole, zacatek, r); QuickSort(pole, l, konec); } } } public void swap(int[] pole, int index1, int index2) { int temp = pole[index1]; pole[index1] = pole[index2]; pole[index2] = temp; } public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { textBox_gen.Text = ""; textBox_gen.Focus(); textBox_bs.Clear(); textBox_qs.Clear(); textBox_as.Clear(); sb_b.Clear(); sb_q.Clear(); sb_a.Clear(); pocet = 0; label_cas_bs.Text = ""; label_cas_qs.Text = ""; label_cas_as.Text = ""; klik_b = 0; klik_q = 0; klik_a = 0; } private void pictureBox1_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("https://www.itnetwork.cz/algoritmy/razeni"); } private void textBox_gen_KeyPress(object sender, KeyPressEventArgs e) { if (!((e.KeyChar >= 48 && e.KeyChar <= 57) || (e.KeyChar == 8))) { e.KeyChar = Convert.ToChar(0); } } private void button_vymaz_Click(object sender, EventArgs e) { textBox_gen.Text = ""; textBox_gen.Focus(); textBox_bs.Clear(); textBox_qs.Clear(); textBox_as.Clear(); sb_b.Clear(); sb_q.Clear(); sb_a.Clear(); pocet = 0; label_cas_bs.Text = ""; label_cas_qs.Text = ""; label_cas_as.Text = ""; klik_b = 0; klik_q = 0; klik_a = 0; } private void button_gen_Click(object sender, EventArgs e) { textBox_bs.Clear(); textBox_qs.Clear(); textBox_as.Clear(); sb_b.Clear(); sb_q.Clear(); sb_a.Clear(); pocet = 0; label_cas_bs.Text = ""; label_cas_qs.Text = ""; label_cas_as.Text = ""; Random generator = new Random(); try { if (textBox_gen.Text == "") { MessageBox.Show("Musíte zadat číslo!", "Upozornění", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); textBox_gen.Focus(); return; } else { pocet = Convert.ToInt32(textBox_gen.Text); if (pocet > 100000) { MessageBox.Show("Zadejte číslo do 100000!","Varování",MessageBoxButtons.OK,MessageBoxIcon.Warning); textBox_gen.Text = ""; textBox_gen.Focus(); return; } else { for(int i=0; i