#include <stdlib.h>
#include<iostream.h>
#include<ctype.h>
# define MAX 1000
class calculator
{
private:
struct save1 //存储数字
{
double n[MAX];
int top;
}
stack1;
struct save2 //存储运算符
{
char n[MAX];
int top;
}
stack2;
public:
calculator(){}; //空的构造函数
bool stack1empty(save1 s);
bool stack2empty(save2 s);
void push1(save1 &s,double num);
void push2(save2 &s,char op);
void pop1(save1 &s,double &num);
void pop2(save2 &s,char &op);
int in(char op);
int out(char op);
void count(double a,char op,double b);
void cal();
};
bool calculator::stack1empty(save1 s) //判断数字栈是否为空
{
if(s.top==-1)
return 1;
else return 0;
}
bool calculator::stack2empty(save2 s)//判断运算符栈是否为空
{
if(s.top==-1)
return 1;
else return 0;
}