//栈类
template <class T>
class ArrayStack
{
public:
int MaxSize;
int top;
T *st;
ArrayStack(int MaxSize)
{
this->MaxSize=MaxSize-1;
top=-1;
st=new T [MaxSize];
}
void Push(T item)
{
st[++top]=item;
}
T Pop()
{
return st[top--];
}
T Top()
{
return st[top];
}
bool IsFull()
{
if(top==MaxSize)
return true;
return false;
}
bool IsEmpty()
{
if(top==-1)
return true;
return false;
}
void Clear()
{
top=-1;
}
};
//运算操作在函数中可能被多次调用,为了避免冗余,将它写成一个函数
int calculate(char opera,int cal1,int cal2)
{
int c;
if(opera=='^')