-
大小: 21KB文件類型: .rar金幣: 1下載: 0 次發(fā)布日期: 2021-01-10
- 語言: 其他
- 標(biāo)簽:
資源簡(jiǎn)介
用二叉樹實(shí)現(xiàn)中綴表達(dá)式轉(zhuǎn)換成后綴表達(dá)式,內(nèi)含一個(gè)CPP文件的代碼和一個(gè)截圖,很不錯(cuò)的,是我自己寫的。
代碼片段和文件信息
#include
#include
#include
#include
using?namespace?std;
class?Tree_Node
{
public:
char?oper;
Tree_Node?*left;
Tree_Node?*right;
Tree_Node(char?op){
left=right=NULL;
oper=op;
}
};
inline?void?free_Tree(Tree_Node?*p)
{
if(p->left!=NULL){
free_Tree(p->left);
}
if(p->right!=NULL){
free_Tree(p->right);
}
delete(p);
}
int?prioritySX(char?op)
{
switch(op){
case?‘(‘:
return?1;
case?‘+‘:
case?‘-‘:
return?2;
case?‘*‘:
case?‘/‘:
return?3;
case?‘^‘:
return?4;
default:
return?0;
}
}
bool?judge(char?op)
{
char?opera[]={‘(‘‘)‘‘+‘‘-‘‘*‘‘/‘‘^‘};
for(int?i=0;i if(op==opera[i]){
return?true;
}
}
return?false;
}
void?post_order(Tree_No
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件??????22120??2010-11-23?16:07??中綴到后綴\截圖.jpg
?????文件???????2611??2010-11-23?16:14??中綴到后綴\用二叉樹實(shí)現(xiàn)中綴表達(dá)式到后綴表達(dá)式的轉(zhuǎn)換.cpp
?????目錄??????????0??2010-11-23?16:17??中綴到后綴
-----------?---------??----------?-----??----
????????????????24731????????????????????3
- 上一篇:beego完檔.chm
- 下一篇:ccs5.3的license注冊(cè)碼
評(píng)論
共有 條評(píng)論