postfixcompute.cpp

来自「postfixComputer, Calculate the postfix e」· C++ 代码 · 共 92 行

CPP
92
字号
#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 + =
减小字号Ctrl + -
显示快捷键?