- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
算术表达式求值实习报告.doc
算术表达式求值实习报告
The information that is worth having
It comes from the general learning accumulation summary
There must be a problem
Please be critical!
Arithmetic expressions evaluate the internship report
Class no.052415 zhu bokai
One, requirements analysis
the program needs users to input expression (operator can be a plus (+), minus (-), multiply (*), in addition to (/), power ():the parentheses (()))
The number can be an integer or a float
Press enter to finish!
program function: computation of arithmetic expressions
The output
And output its postfix expression!
test data:
8; 1 + 2 + 3 + 4;
88-1 * 3; 1024/8 * 16;
1024 / (8 * 16); (22 + 3) * (8/2);
The 3-3-3; 8 / (9-9);
2 times 5 plus 3 times 2 plus 4 times 3 plus 6.
Second, profile design
To implement the above program functions
The Numbers and operators in the expression should be stored separately from the stack of two leading nodes
The abstract data type definition of the stack
ADT Stack {
The data object: 〃d 二{ai | ai, 〃 the 〃I 二 1, 2, 3, 〃???
n
N p 0}
Data relations: r = {ai - 1, ai,) | ai -1, ai unit d, 1 = 2, 3,…
N}
Contract al is the bottom of the stack
The an is the top
Basic operation:
InitStack ( S)
Operation result: construct an empty stack S
DestroyStack ( S)
Initial conditions: stack S already exists
Operation result: destroy stack S
ClearStack ( S)
Initial conditions: stack S already exists
The result: empty the stack as an empty stack
StackEmpty ( S)
Initial conditions: stack S already exists
Operation result: if stack S is empty stack
It returns TRUE,
Otherwise, FALSE
StackLength ( S)
Initial conditions: stack S already exists
Operation result: return the length of the stack (or depth)
GetTop (S
e)
Initial conditions:
stack S is already present and not empty
Operation result: the stack top element of S returned with e
Push ( S, e)
Initial conditions: stack S already exists
Operation result: insert new element e at the top of the stack
Pop ( S, e)
Initial conditions: stack S is already
文档评论(0)