美文网首页
数据结构(9.13)

数据结构(9.13)

作者: 文方方 | 来源:发表于2017-09-17 12:25 被阅读0次

1.求算术表达式的值

others' mentality

first, find out the suffix expression.

put the string in an array and named as exp, and define another array named postexp, which is to put the suffix expression. The two arraies are typed of char.  In order to make the trance come true, a operation stack is necessary. A stack is named as op to stor the operations in the original expression. To follow the rule of caculation, we need to define the primary of the opertaions as the following table. ps.the lpri means the char from the exp in the process of traversal. the rpri is the char in the op.

if the leftpri's primary is higher than the right one, which means that the operation should be poped from the op and putted into the postexp; else if the leftpri's primaty is lower than the right one, which means that the operation was put into op and the traversal goes on. else, get out all the left operations in the op in order and put them in the postexp. The postexp is the suffix expersion of the orgiainal expression.

Second, do operation with the postexp.

A number stack is necessary, which is to put the result of each stp of operation.

Traversal op and when meet numbers get out and get it stored in the stack and when meet an operation, get out two numbers from the number stack and do the operation with the numbers that you get out from the stack and put the result back to the stack untile the postexp is traversaled over.

Code written with the help of book

5.Summary

stray \241  or  \243 in program means that there are Chinese input

When I get a problem, I should be clam down and try to find the solution with the knowledge that I have learnt, just to try it.

相关文章

  • 数据结构(9.13)

    1.求算术表达式的值 others' mentality first, find out the suffix e...

  • 2017-09-13

    「9.13」

  • 9.13

    ”9.13” 鲜为多人知晓的董老的诗。 中国文革史上的“9.13”事件(令人“迷”一样)...

  • 21/8股票记录

    600601 买入9.13 x1095

  • 论语·子罕篇9-13.14.15.16

    9.13[传统为9.13]子贡曰:“有美玉于斯,韫椟而藏诸?求善贾而沽诸?”子曰:“沽之哉!沽之哉!我待贾者也。”...

  • 9.13

    请假,上午回父母家,一则辞节~1000,一则为母亲送益生菌,教师节,给父亲300元。小舅8.11生日,送50...

  • 9.13

    今日长难句 In short, the image that best represents the curren...

  • 9.13

    今天任务日程 建发,进口货推进。关注TDI 订聚醚和330 模仿一篇推文,发送到朋友圈和其他渠道(开始渠道分发)什...

  • 9.13

    从事物发展规律到成长性思维 一,对立统一规律,即矛盾规律 简单来讲,事物在“好”和“坏”之间转变。例如手机的发明,...

  • 9.13

    有这样一个问题,如何可以碎片化最大程度的利用手机?我该用它干什么? 人不能完全随心所欲,因为人性是复杂的,你可能是...

网友评论

      本文标题:数据结构(9.13)

      本文链接:https://www.haomeiwen.com/subject/umklsxtx.html