题目
Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.
Input Specification:
Each input file contains one test case. For each case, the first line gives a positive integer N(≤20)N(\le20)N(≤20) which is the total number of nodes in the syntax tree. Then NNN lines follow, each gives the information of a node (the iii-th line corresponds to the iii-th node) in the format:
data left_child right_child
where data is a string of no more than 10 characters, left_child and right_child are the indices of this node’s left and right children, respectively. The nodes are indexed from 1 to NNN

根据给定的二叉树结构,输出相应的中缀表达式,考虑运算符优先级,正确使用括号。
最低0.47元/天 解锁文章
187

被折叠的 条评论
为什么被折叠?



