Exemple #1
0
 private void btnCreate_Click(object sender, EventArgs e)//СОздать дерево
 {
     try
     {
         myTour = new MyTour();
         int L = 0;
         for (int i = 0; i < richTextBox1.Lines.Count(); i++)
         {
             if (richTextBox1.Lines[i] != "")
             {
                 L++;
             }
         }
         myTour.a     = new int[L];
         myTour.array = new Node[0];
         for (int i = 0; i < L; i++)
         {
             if (richTextBox1.Lines[i] != "")
             {
                 myTour.a[i] = Convert.ToInt32(richTextBox1.Lines[i]);
             }
         }
         myTour.head = myTour.HeapCreate(ClientRectangle.Height);
         myTour.g    = this.CreateGraphics();
         myTour.Draw();
         btnSort.Enabled     = true;
         btnAutoSort.Enabled = true;
     }
     catch
     {
     }
 }
Exemple #2
0
        private void btnAutoSort_Click(object sender, EventArgs e)
        {
            btnAutoSort.Enabled = false;
            btnSort.Enabled     = false;
            int L = 0;

            for (int i = 0; i < richTextBox1.Lines.Count(); i++)
            {
                if (richTextBox1.Lines[i] != "")
                {
                    L++;
                }
            }
            for (int i = 0; i < L; i++)
            {
                ar.Add(Convert.ToInt32(myTour.head.data));
                myTour.Competition(ref myTour.head);
            }
            richTextBox1.Text = "";
            string s = "";

            for (int i = 0; i < ar.Count; i++)
            {
                s += ar[i] + "\r\n";
            }
            ar.Clear();
            richTextBox1.Text   = s;
            btnSort.Enabled     = false;
            btnAutoSort.Enabled = false;

            myTour = new MyTour();
            L      = 0;
            for (int i = 0; i < richTextBox1.Lines.Count(); i++)
            {
                if (richTextBox1.Lines[i] != "")
                {
                    L++;
                }
            }
            myTour.a     = new int[L];
            myTour.array = new Node[0];
            for (int i = 0; i < L; i++)
            {
                if (richTextBox1.Lines[i] != "")
                {
                    myTour.a[i] = Convert.ToInt32(richTextBox1.Lines[i]);
                }
            }
            myTour.head = myTour.HeapCreate(ClientRectangle.Height);
            myTour.g    = this.CreateGraphics();
            myTour.Draw();
            btnSort.Enabled     = true;
            btnAutoSort.Enabled = true;
        }