题目:逆波兰表达式(后缀表达式的求解)
<span style="font-size:18px;">#include<iostream>
#include<stack>
using namespace std;
enum type
{
OP_NUM,
OP_SYMBLE,
ADD,
SUB,
MUL,
DIV
};
struct Cell
{
type _type;
int _value;
};
int RPN_ARRAY(Cell Array[], size_t size )
{
size_t i = 0;
stack<int > s;
for (i = 0; i< size ; i++)
{
if (Array [i]._type == OP_NUM)
{
s.push( Array[i]._value);
}
else
{
int right = s.top();
s.pop();
int left = s.top();