文件名称:formula-for-calculating--true-value
介绍说明--下载内容均来自于网络,请自行研究使用
计算命题演算公式的真值,所谓命题演算公式是指由逻辑变量(其值为TRUE或FALSE)和逻辑运算符∧(AND)、∨(OR)和┐(NOT)按一定规则所组成的公式(蕴含之类的运算可以用∧、∨和┐来表示)。公式运算的先后顺序为┐、∧、∨,而括号()可以改变优先次序。已知一个命题演算公式及各变量的值,要求设计一个程序来计算公式的真值。
要求:
(1)利用二叉树来计算公式的真值。首先利用堆栈将中缀形式的公式变为后缀形式;然后根据后缀形式,从叶结点开始构造相应的二叉树;最后按后序遍历该树,求各子树之值,即每到达一个结点,其子树之值已经计算出来,当到达根结点时,求得的值就是公式之真值。
(2)逻辑变元的标识符不限于单字母,而可以是任意长的字母数字串。
(3)根据用户的要求显示表达式的真值表。
-Propositional calculus formula for calculating the true value, the so-called propositional calculus formula refers to a logical variable (its value is TRUE or FALSE) and the logical operators ∧ (AND), ∨ (OR) and ┐ (NOT) according to certain rules of composition of the formula (contains the kind of computing can ∧, ∨ and ┐ expressed). Formula computing the order of ┐, ∧, ∨, and parentheses () can change the priorities. Given a propositional calculus formula and the value of a variable, to design a program to calculate the formula for the true value.
Requirements:
(1) the use of binary tree to calculate the true value of the formula. First, the stack will use the formula in infix form into postfix form then the postfix form, starting from the leaf node corresponding binary tree structure press the post-order traversal of the tree, find the value of each sub-tree, that is, each reaching a node, the value of its sub-tree has been calculated and when it reaches the root node, the obtain
要求:
(1)利用二叉树来计算公式的真值。首先利用堆栈将中缀形式的公式变为后缀形式;然后根据后缀形式,从叶结点开始构造相应的二叉树;最后按后序遍历该树,求各子树之值,即每到达一个结点,其子树之值已经计算出来,当到达根结点时,求得的值就是公式之真值。
(2)逻辑变元的标识符不限于单字母,而可以是任意长的字母数字串。
(3)根据用户的要求显示表达式的真值表。
-Propositional calculus formula for calculating the true value, the so-called propositional calculus formula refers to a logical variable (its value is TRUE or FALSE) and the logical operators ∧ (AND), ∨ (OR) and ┐ (NOT) according to certain rules of composition of the formula (contains the kind of computing can ∧, ∨ and ┐ expressed). Formula computing the order of ┐, ∧, ∨, and parentheses () can change the priorities. Given a propositional calculus formula and the value of a variable, to design a program to calculate the formula for the true value.
Requirements:
(1) the use of binary tree to calculate the true value of the formula. First, the stack will use the formula in infix form into postfix form then the postfix form, starting from the leaf node corresponding binary tree structure press the post-order traversal of the tree, find the value of each sub-tree, that is, each reaching a node, the value of its sub-tree has been calculated and when it reaches the root node, the obtain
(系统自动生成,下载前可以参看下载内容)
下载文件列表
四 计算命题演算公式的真值.doc