Пример #1
0
        public static void Main(string[] args)
        {
            BinaryTree myTree = new BinaryTree ();
            using (StreamReader fileIn = new StreamReader ("/Users/masha/Documents/ssu/c_sharp/Pr15R1ex5/Pr15R1ex5/input.txt"))
            {

                string line = fileIn.ReadToEnd ();
                string[] mas = line.Split (' ');

                foreach (string item in mas)
                    myTree.Add (int.Parse(item));

                int sum = 0;
                sum += Convert.ToInt32(myTree.Walk(myTree.Tree));

                Console.WriteLine ("{0}",sum);
            }
        }
Пример #2
0
        public static void Main(string[] args)
        {
            Console.WriteLine ("Hello World!");
            BinaryTree bt = new BinaryTree ();

            string ins = "-a*b+/cd/ef";

            for (int i = 0; i < ins.Length; i++)
            {
                bt.Add (ins [i]);
            }

            bt.Preorder ();
            Console.WriteLine ();
            bt.Postorder ();
            Console.WriteLine ();
            bt.Inorder ();
        }