Postfix To Infix转换

编程入门 行业动态 更新时间:2024-10-23 07:18:10
本文介绍了Postfix To Infix转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要帮助在c ++程序中将表达式Postfix转换为Infix表单.... Plz任何一个帮助......

解决方案

首先使用你的笔记本实现将后缀转换为中缀的过程。 用C ++搞清楚方法工具后,我就是这样做的其他程序员

让我为你打护 [ ^ ] 。 但是我建议你至少根据你的理论知识进行一次尝试(你研究过这个问题,对吗?)。

Pseudo-代码:

string input = ReadInput(); Stack< string>堆; foreach(字符串标记 GetTokens(输入)){ if (IsOperator) (令牌)){ string a = stack.Pop(); string b = stack.Pop(); stack.Push( ( + b + token + a + )); } else { stack.Push(token); } } print(stack.Pop());

上面没有显示错误处理,即垃圾进入→垃圾-out。 转换成C ++是留给你的练习。 祝你好运! Andi

I need help to convert an expression Postfix To Infix form in c++ program.... Plz any one help...

解决方案

First implement the process of converting postfix to infix using your notebook. After figuring out the method implement with C++, that was how I did as well as all other programmer did

Let Me Goggle That For You[^]. However I would suggest yoo to make at least an attempt based just on you theoretical knowledge (did you study the matter, right?).

Pseudo-code:

string input = ReadInput(); Stack<string> stack; foreach(string token in GetTokens(input)) { if (IsOperator(token)) { string a = stack.Pop(); string b = stack.Pop(); stack.Push("(" + b + token + a + ")"); } else { stack.Push(token); } } print(stack.Pop());

No error handling shown above, i.e. garbage-in→garbage-out. Conversion into C++ is left to you as exercise. Good Luck! Andi

更多推荐

Postfix To Infix转换

本文发布于:2023-10-13 00:07:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1486257.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Postfix   Infix

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!