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); }
public ArTree() // Конструктор { root = null; }