application2.cs

来自「Data Structures and Algorithms with Obj」· CS 代码 · 共 43 行

CS
43
字号
namespace Opus6
{
    using System;
    using System.Drawing;
    using System.Windows.Forms;

    [Version("$Id: Application2.cs,v 1.4 2001/11/04 20:49:34 brpreiss Exp $"), Copyright("Copyright (c) 2001 by Bruno R. Preiss, P.Eng.")]
    public class Application2 : TTY
    {
        private static NaryTree BuildTree(char lo, char hi)
        {
            char ch1 = Convert.ToChar((Convert.ToInt32(lo) +Convert.ToInt32( hi)) / '\x0002');
            NaryTree tree1 = new NaryTree(2, ch1);
            if (lo < ch1)
            {
                tree1.AttachSubtree(0, Application2.BuildTree(Convert.ToChar(lo), Convert.ToChar(Convert.ToInt32(ch1) - '\x0001')));
            }
            if (hi > ch1)
            {
                tree1.AttachSubtree(1, Application2.BuildTree(Convert.ToChar(Convert.ToInt32(ch1) + '\x0001'), hi));
            }
            return tree1;
        }

        public static void Main()
        {
            Form form1 = new Form();
            form1.Size = new Size(490, 380);
            form1.Controls.Add(new Application2());
            Application.Run(form1);
        }

        public override void Run()
        {
            Opus6.Console.WriteLine("Should be: dbfaceg.");
            Tree tree1 = Application2.BuildTree('a', 'g');
            Algorithms.BreadthFirstTraversal(tree1);
        }

    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?