学习数据结构的知识,第一课便是栈结构。
要注意栈是一端封闭,另一端开口的数据存储结构,所以存的时候就像是们盛饭的时候,碗里的饭是慢慢多到顶的,取出来的时候就像吃的时候,慢慢到底。
这就是说 先入的后出,或者说后入先出。
下面是实现栈结构的代码:
//超超
//2016/10/5日
#include <iostream>
using namespace std;
enum error_code{success,overflow,underflow,rangeerror};
typedef int elementtype ;
const int maxlen=15;
class stack{
public:
stack();
bool isempty()const;
bool isfull() const;
error_code get_top(elementtype &x)const;
error_code push(const elementtype x);
error_code pop();
private:
int count;