Ejemplo n.º 1
0
        private void btnCreate_Click(object sender, EventArgs e)//СОздать дерево
        {
            //int L = richTextBox1.Lines.Count();
            //for(int i =0; i<L; i++)
            //{
            //    if (richTextBox1.Lines[i]!="")
            //    {
            //        int k = Convert.ToInt32(richTextBox1.Lines[i]);
            //        myTree.Insert(ref myTree.top, k, 200, 40);

            //    }
            //}
            myTree = new MyTree();

            Random r = new Random();

            for (int i = 0; i < 1000; i++)
            {
                // myTree.k = 15;
                int k = r.Next(0, 100);
                myTree.Insert(ref myTree.top, k, 200, 40);
            }

            myTree.g = this.CreateGraphics();
            myTree.g.Clear(Color.WhiteSmoke);
            myTree.DrawNode(myTree.top);
            myTree.Array();
            myTree.SetStrSort(myTree.top);
            myTree.FindNode(myTree.top, 200, 200);
            richTextBox1.Text = "";
            for (int i = 0; i < 100; i++)
            {
                richTextBox1.Text += Convert.ToString(i) + " : " + Convert.ToString(myTree.array[i]) + "\r\n";
            }
            richTextBox1.Enabled = true;

            //btnAdd.Enabled = true;
            //btnDelete.Enabled = true;
            //btnFind.Enabled = true;
            //BtnSortAr.Enabled = true;
        }