⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stack.cpp

📁 此为编译原理的作业中的预测分析表的生成的原代码
💻 CPP
字号:
//STACK
#include"Stack.h"
#include<stdlib.h>
#include<iostream.h>
Stack::Stack(){
		top=rear=0;
		S=new ElemType[STACK_LEN];
	}
Stack::Stack(int len){
        top=rear=0;
		S=new ElemType[len];
	}
Stack::~Stack(){
		delete []S;
	}
void Stack::Push(ElemType e){
		if((top-rear)!=STACK_LEN-1)
			S[top++]=e;
		else {
			cout<<"堆栈已经满了,为了程序能够继续请重新设置栈的长度!"<<endl;
			exit(1);
		}
	}
ElemType Stack::Top(){
		if(top!=rear)
			return S[top-1];
	}
ElemType Stack::Pop(){
		if(top!=rear)
			return(S[--top]);
	}
int Stack::Length(){
		return top-rear;
	}


	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -