来源:互联网 发布:python 金融数据接口 编辑:程序博客网 时间:2024/06/07 00:52

栈是一种线性表,其插入和删除操作都只能在表的一端进行,这一端称为栈顶,而另一端称为栈底!   

直接上代码!


#include <iostream>#include <cstdlib>using namespace std;#define max 10000struct element{//定义栈 int key;};element stack[max];int top = -1;bool is_empty()//判断栈是否为空 {return top < 0;}bool is_full()//判断栈是否已满 {return top >= max-1;}void push(element item)//入栈操作 {if (top >= max-1)exit(1);stack[++top] = item;}void pop()//出栈操作 {if (top == -1)exit(1);top -- ;}element top1()//访问栈顶元素 {if (top == -1)exit(1);return stack[top];}int main(){return 0;}


0 0