Пример #1
0
 private void Add(Node pos, bool check)
 {
     char c = 'a';
     if (countOfExample < example.Length)
     {
         c = example[countOfExample];
         ++countOfExample;
         if (c != '(' && c != ')' && c != ' ')
         {
             Node temp = TypeOfNode(c);
             temp.Value = c;
             if (check)
             {
                 pos.Left = temp;
             }
             else
             {
                 pos.Right = temp;
             }
             Add(pos.Left, true);
             Add(pos, false);
         }
         if (c == '(')
         {
             Add(pos, true);
         }
     }
 }
Пример #2
0
 public CountTree(string s)
 {
     root = new Add();
     countOfExample = 0;
     using (StreamReader f = new StreamReader(s))
     {
         example = f.ReadLine();
     }
     Add(root, true);
 }