コード例 #1
0
        public double Calculation(ref bool value, ArNode root)
        {
            double right;
            double result = 0;
            double left;

            if (value && (root != null))
            {
                right = Calculation(ref value, root.Right);
                left  = Calculation(ref value, root.Left);
                if (value)
                {
                    switch (root.act)
                    {
                    case '+':
                        result = right + left;
                        break;

                    case '*':
                        result = left * right;
                        break;

                    case '-':
                        result = left - right;
                        break;

                    case '/':
                        if (right != 0)
                        {
                            result = left / right;
                        }
                        else
                        {
                            value = false;
                        }
                        break;
                    }
                }
            }
            return(result);
        }
コード例 #2
0
 public ArTree() // Конструктор
 {
     root = null;
 }