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

📄 mystack_e.cpp

📁 中缀表达式转中缀表达式
💻 CPP
字号:
#ifndef MYSTACK_E_H
#define MYSTACK_E_H

#include"mystack.h"

template<class DataType>
SepStack<DataType>::SepStack(){
	pdata = new DataType [MaxNum];
	if (pdata==NULL)
		cout<<"There is no space!\n";
	else
		t = -1;
}

template<class DataType>
int SepStack<DataType>::isEmptyStack(){
	return(t==-1);
}

template<class DataType>
void SepStack<DataType>::push(DataType x){
	if (t<MaxNum-1)
	{
		t++;
		pdata[t] = x;
	}
	else cout<<"Stack is full!!\n";
}

template<class DataType>
DataType SepStack<DataType>::pop(){
	assert(!isEmptyStack());
	return pdata[t--];
}

template<class DataType>
DataType SepStack<DataType>::top(){
	//if the stack is not empty
	return(pdata[t]);
}

template<class DataType>
void SepStack<DataType>::clear(){
	t = -1;
	delete [] pdata;
}

#endif

⌨️ 快捷键说明

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