数据结构实验——中缀表达式向后缀表达式的转化(包括四则运算和幂运算)——详细注释(Conversion of data structure experiment infix expression to suffix expression (including the four operations and exponentiation), detailed notes).doc
- 1、本文档共17页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
数据结构实验——中缀表达式向后缀表达式的转化(包括四则运算和幂运算)——详细注释(Conversion of data structure experiment infix expression to suffix expression (including the four operations and exponentiation), detailed notes)
# includes stdio.h
# includes stdlib.h
/ *
输入输出说明:
输入.
输入一中缀表达式并紧接符号 # 以结束输入.
输入样例如下.
a + b + c + d + e + f) * g #
c * a + b * d - (e + f * g) * h #
a * (b + c) / (d + e + f) + (g) - (h #
输入注意, 括号一律用圆括号
输出.
输出相应后缀表达式.
输出样例如下.
abc * + de * f + g * +
ca * bd * + * + h * - efg
abcde + f + / + g + * h
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
带幂运算的优先级顺序 (左低右高)
+, +, -
+, -,
注意.
加减具有同一优先级.
乘除具有同一优先级.
且幂运算 ^ 与乘法运算 *
的优先级顺序不具有可比性! !
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
样例输入:
3 * 6 ^ 5 * 2 #
3 * 2 ^ 3 ^ 2 ^ 2 ^ 3 + 2 * 5 - 5 #
6 + 3 * 2 ^ 3 * 2 ^ 2 ^ 3 + 4 + 5 #
样例输出:
3652 * ^ *
323223 ^ ^ ^ ^ *? 5 * + 5 -* ^ ^ * ^ * + 5 +
注意:
第二组数据输出中的 ? 本该是 2.
经过长时间测试及数据对比, 至今仍未找到确切原因.
故尚且属于未知错误, 作特殊情况处理! !
* /
struct hi
{
char ch;
hi * next;
};
hi * plus _ pettigrew (hi * tempstack)
{
while (tempstack! = = null)
{
if (tempstack - ch = = 1 / / 如果遇到左括号就返回 空
{
return null; / / 因为说明要输入的元素本身就包含在一组括号中
}
else if (tempstack - ch = = + | | tempstack - ch = = -)
{
return tempstack;
}
tempstack = tempstack - next;
}
return null; / / 没有找到优先级更高的则返回 空
}
hi * hap _ div (hi * tempstack)
{
while (tempstack! = = null)
{
if (tempstack - ch = = (| | tempstack - ch = = 2)
{
return null;
}
else if (tempstack - ch = = * | | tempstack - ch = = /)
{
return tempstack;
}
tempstack = tempstack - next;
}
return null;
}
hi power (hi * * tempstack, hi * temptail)
{
while (tempstack! = = null)
{
if (tempstack - ch = = ()
{
return null;
}
else if (tempstack - ch = = 6) / / 如果有幂运算就全部弹出
{
return temptail; / / 所以返回尾部地址
}
tempstack = tempstack - next;
}
return null;
}
the * sign (hi * tempstack)
{
while (tempstack! = = null)
{
if (tempstack - ch = = ()
{
return tempstack;
}
tempstack = tempstack -下;
}
返回null;
}
国际main
您可能关注的文档
- 6.1 模板(6.1 templates).doc
- 06全口带入及问题(06 full mouth intake and problems).doc
- 6aunit3第一课时(6aunit3 first class).doc
- 6级英语单词p(6 English words p).doc
- 7 给水排水(7 water supply and drainage).doc
- 7 地形图测绘(7 topographic mapping).doc
- 7.4《流体压强与流速的关系》说课稿(7.4 the relation between fluid pressure and velocity).doc
- 7.3使用燃料对环境的影响(7.3 environmental impact of the use of fuel).doc
- 7a单词(7A word).doc
- 7侧翼理论(7 flank theory).doc
- 数据结构算法演示(Windows版)(Data structure algorithm demonstration (Windows version)).doc
- 数据结构题目(Data structure title).doc
- 数据结构实验一答案(Data structure experiment one answer).doc
- 数据结构图的建立与计算(Establishment and calculation of data structure diagram).doc
- 数据结构习题与答案(Data structure exercises and answers).doc
- 数据结构-停车场程序(Data structure - parking procedures).doc
- 数据结构与算法常用英语词汇(Data structures and algorithms commonly used in English Vocabulary).doc
- 数据结构与网络游戏(Data structures and online games).doc
- 数据结构中串的各种算法(Data structure string of various algorithms).doc
- 数据流程与业务流程的区别(The difference between a data process and a business process).doc
最近下载
- 金刚砂耐磨地坪工程劳务施工合同协议书范本.doc
- 保健食品原料目录 营养素补充剂(2023年版).docx
- SA51024矽力杰 中文资料 规格书 pdf 下载电源管理芯片全线.pdf VIP
- 《2024年中国公共充电桩行业市场研究报告》.pdf
- XXX项目_临时占用农田和生态保护红线不可避让性论证报告.pdf
- 《“名师工作室”引领教师专业化成长的策略研究》申报评审书).doc VIP
- 22G101 三维彩色立体图集.docx
- 新城吾悦广场消防系统维修保养及消防改造安全施工技术方案.doc
- 无人机在矿山监测中的应用.ppt
- 2024年山东省中考数学真题卷(适合枣庄、临沂、聊城、菏泽)(含答案与解析).docx VIP
文档评论(0)