目前只支持+-*/以及英文的()的简单运算
详情见注释
//easy caculator
//
//Created by zzx on 2018.10.10
#include <iostream>
using namespace std;
#include <string>
#include <stdlib.h>
#define MaxSize 100
char precede(char a, char b);
template <class T>
class stack {
private:
int top;
T data[MaxSize] = { 0 };
public:
void intstack(stack <T> *s)//初始化栈
{
s->top = 0;
}
int isEmpty(stack<T> *s)//判断栈空
{
if (s->top == 0)
{
return 0;
}
return 1;
}
int isfull(stack <T> *s)//判断栈满
{
if (s->top == MaxSize)
return 0;
return 1;
}
int push(stack <T> *s, T x)//进栈
{
if (!isfull(s))
{
return -1;
}
else
{
if (!isEmpty(s))
top = 0;
s->top++;
s->data[s->top - 1] = x;
}
return 0;
}
T pop(stack <T> *s)//栈顶元素出栈
{
if (!isEmpty(s))
return -1;
else
{
T x;
x = s->data[s->