📄 postfixcompute.cpp
字号:
#include "stdafx.h"
#include "BTree.h"
#include "BTreeNode.h"
#include "InfixToPostfix.h"
#include "PostfixToBTree.h"
#include<iostream>
#include<string>
#include<stack>
#include<cctype>
#include<vector>
#include<maths>
using namespace std;
int PostFixCompute(BTreeNode<T> *root);
{
if( root == NULL)
{
cout<<"Empty!"<<endl;
return 0;
}
else if(root->isLeaf())//判断是否为叶结点
cout<<root->value<<endl;
return 1;
else
{
stack s;
int temp,a,b;
while(!root == NULL)
{
while(!root->leftchild->isLeaf())//判断左子树结点是否为叶结点
{
root = root->leftchild;
}
a = root->leftchild->value;
if (!root->rightchild==NULL)
b = root->rightchild->value;
temp =root->value;
root->value = a temp b;
else
{
while(!root==NULL)
{
root = root->leftchild;
}
a = root->leftchild->element;
if(!root->rightchild==NULL)
PostOrder(root->leftchild);
PostOrder(root->rightchild);
Visit(root);//后序周游二叉树或其子树
}
temp = root->element;
cout<<temp<<endl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -