expresscompute.cpp

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

CPP
63
字号
// ExpressCompute.cpp : Defines the entry point for the console application.
//

#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>

using namespace std;


void main()
{
	int InfixToPostfix();//将输入的中缀表达式转换成后缀表达式

	BTreeNode *PostfixToBTree(vecPostfix[]);//将得到的后缀表达式转换成二叉树

	int PostFixCompute(*pointer);//后序遍历该二叉树,计算并输出表达式的值
	{
		stack<char> s;

		string operatorSymbol = "+-*/()";

		enum state{OPERAND, OPERATOR};

		stack s;
		
		int temp;

		do
		{
			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 + -
显示快捷键?