急求大神帮小弟我运行一下,看看那里出有关问题了,关于栈和队列的应用
急求大神帮我运行一下,看看那里出问题了,关于栈和队列的应用
// Huiwen.h: interface for the Huiwen class.
#include <iostream.h>
#define m 100
typedef struct stackstru // 定义栈
{
char stack[m];
int *base;
int *top;
int stacksize;
}stackstru;
typedef struct queuestru //定义队列
{
int *base;
int front;
int rear;
}queuestru ;
class Huiwen
{
public:
Huiwen();
virtual ~Huiwen();
int InitStack(stackstru &s); //初始化栈
void ClearStack(stackstru &s); //清空栈
int StackEmpty(stackstru &s); //判断栈是否空
int Push(stackstru &s,char x); //入栈操作
char Pop(stackstru &s); //出栈操作
int InitQueue(queuestru &q); //初始化为一个空的循环队列
void ClearQueue(queuestru &q); //清空队列
int QueueEmpty(queuestru &q); //判断队列是否为空
int EnQueue(queuestru &q,char e); //入队操作
char DeQueue(queuestru &q); //出队操作
};
// Huiwen.cpp: implementation of the Huiwen class.
#include "Huiwen.h"
#include "iostream.h"
#include "stdlib.h"
#define INCREASE 10
#define INITSIZE 100
#define OVERFLOW 0
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
Huiwen::Huiwen()
{
}
Huiwen::~Huiwen()
{
}
//初始化栈
int Huiwen::InitStack(stackstru &s)
{
s.base = (int*)new int[INITSIZE];
if(!s.base)
exit(OVERFLOW);
s.top = s.base ;
s.stacksize =INITSIZE;
return OK;
}
//清空栈
void Huiwen::ClearStack(stackstru &s)
{
s.top=0;
}
//判断栈是否空
int Huiwen::StackEmpty(stackstru &s)
{
if (s.top==0) //栈顶为空
return FALSE;
else
return TRUE;
}
//入栈操作
int Huiwen::Push(stackstru &s,char x)