当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1855:Expressions

题目描述
Have you taken the course named Data Structure? Did you pass it? If you do, you should know that a mathematical expression can be expressed as a tree and why. In this problem, you are given some expressions, and you are supposed to draw the tree.

The expressions are composed of these letters:
(1) 'a', 'b', ..., 'z' : means an operand;
(2) '+', '-', '*', '/' : dyadic operator, means plus sign, subtraction sign, multiplication sign and division sign;
(3) '-' : monadic operator, means negative sign;
(4) '(', ')' : used in pairs to alter priority.
输入解释
Input consists of multiple expressions each on a line (not exceed 50 letters). You should proceed to the end of file.
输出解释
For each expression, You should draw a tree that can express it, following the styles indicated in the sample output.

Note that the '#' in the sample are supposed to tell you that there are spaces at the back of some lines, and you should ignore it in your output.


输入样例
a+b+c
(a-a)*b+(-c)
输出样例
   + #
 +  c#
a b  #
     +  #
   *  - #
 -  b  c#
a a     #
来自杭电HDUOJ的附加信息
Author MDZfirst@TJU
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-1855

最后修改于 2020-10-25T22:48:19+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000/1000MS(Java/Others) 32768/65535K(Java/Others)