前言-
哈喽大家好,我是大鹏,目前是大二的一名学生,今天提供给大家算法与数据结构的一道实验题,有不足之处还请各位大佬指正,好了,废话不多说,咱们直接看代码。
#include<bits/stdc++.h>
using namespace std;
#define MaxSize 100
typedef float ElemType;
typedef struct stack{
ElemType *ch;
int top;
}SqStack;//定义栈
SqStack OPND,OPTR;//定义符号栈和数据栈
float InitStack(SqStack &s)
{
s.ch=new ElemType[MaxSize];
if(!s.ch)return 0;
s.top=0;
return 1;
}//初始化栈
float Push(SqStack &s,ElemType c)
{
if(s.top == MaxSize-1)return 0;
s.ch[s.top++] = c;
return 1;
}//向栈里面添加元素
float Pop(SqStack &s,ElemType &c)
{
if(s.top==0)return 0;
c = s.ch[--s.top] ;
return 1;
}//向栈里面提取元素
ElemType GetTop(SqStack s)
{
if(s.top==0) return 0;
return s.ch[s.top-1] ;
}//获得栈里面在最顶层的元素
bool isEmpty(SqStack s)
{
return s.top==0;
}//判断现在栈是否为空
float Operate(ElemType a, char the