Postfix To Infix转换 [英] Postfix To Infix Conversion
本文介绍了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转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文