📄 stack.h
字号:
#ifndef Stack_SFSFSF
#define Stack_SFSFSF
#include<iostream>
#include<string>
using namespace std;
template<class entrytype>
class Stack{
public:
Stack();
bool empty() const;
int get_top(entrytype &) const;
int push(const entrytype x);
int pop();
bool full() const;
private:
entrytype data[100];
int count;
};
template<class entrytype>
Stack<entrytype>::Stack() {count=0;}
template<class entrytype>
bool Stack<entrytype>::empty() const{
if(count==0) return true;
else return false;
}
template<class entrytype>
int Stack<entrytype>::get_top(entrytype &x) const{
if(empty()) return 0;
else{
x=data[count-1];
return 0;
}
}
template<class entrytype>
int Stack<entrytype>::push(const entrytype x){
if(full()) return 1;
else{
data[count++]=x;
return 0;
}
}
template<class entrytype>
int Stack<entrytype>::pop(){
if(empty()) return 1;
else count--;
return 0;
}
template<class entrytype>
bool Stack<entrytype>::full() const {
if(count==100) return true;
else return false;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -